From c856f8cd15c3df1cf2c26da4a589bba0bf9d1cdb Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 4 Oct 2023 17:46:15 +0900 Subject: [PATCH 01/66] WIP --- MagicOnion.sln | 16 +- .../MagicOnion.Client.SourceGenerator.csproj | 25 ++ .../MagicOnionClientSourceGenerator.cs | 44 +++ .../CodeAnalysis/MethodCollector.cs | 3 +- .../MagicOnionCompiler.cs | 123 +++--- .../GenerateServiceTest.cs | 199 ++++++++++ .../GenerateStreamingHubTest.cs | 353 ++++++++++++++++++ .../GenerateTest.cs | 80 ++++ .../GenerateWithIfDirectiveTest.cs | 67 ++++ ...cOnion.Client.SourceGenerator.Tests.csproj | 38 ++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../TempProject_MyServiceClient.cs | 62 +++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 82 ++++ .../TempProject_MyServiceClient.cs | 54 +++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../TempProject_MyServiceClient.cs | 54 +++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../TempProject_MyServiceClient.cs | 54 +++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../TempProject_MyServiceClient.cs | 54 +++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 91 +++++ .../Complex/TempProject_MyHubClient.cs | 123 ++++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 88 +++++ .../TempProject_MyHubClient.cs | 83 ++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../TempProject_MyHubClient.cs | 83 ++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../TempProject_MyHubClient.cs | 83 ++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 88 +++++ .../Parameter_Many/TempProject_MyHubClient.cs | 77 ++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../Parameter_One/TempProject_MyHubClient.cs | 77 ++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 82 ++++ .../Parameter_Zero/TempProject_MyHubClient.cs | 77 ++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../Return_Task/TempProject_MyHubClient.cs | 77 ++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 82 ++++ .../Return_TaskOfT/TempProject_MyHubClient.cs | 77 ++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../TempProject_MyHubClient.cs | 77 ++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 82 ++++ .../TempProject_MyHubClient.cs | 77 ++++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 98 +++++ .../MyNamespace_MyServiceClient.cs | 54 +++ ...nion_Formatters_ApartmentStateFormatter.cs | 33 ++ ...atters_ClientCertificateOptionFormatter.cs | 33 ++ ...MagicOnion_Formatters_FileModeFormatter.cs | 33 ++ ...Formatters_TaskCreationOptionsFormatter.cs | 33 ++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 105 ++++++ .../MyNamespace_MyServiceClient.cs | 54 +++ .../Test1/MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 88 +++++ .../MyApplication1_GreeterServiceClient.cs | 62 +++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../TempProject_MyServiceClient.cs | 54 +++ .../MagicOnion_MagicOnionInitializer.cs | 97 +++++ ...MagicOnion_Resolvers_MagicOnionResolver.cs | 83 ++++ .../TempProject_MyHubClient.cs | 83 ++++ .../Usings.cs | 2 + .../MagicOnionSourceGeneratorVerifier.cs | 132 +++++++ 79 files changed, 6491 insertions(+), 55 deletions(-) create mode 100644 src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj create mode 100644 src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/GenerateWithIfDirectiveTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MyNamespace_MyServiceClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MyApplication1_GreeterServiceClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Usings.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs diff --git a/MagicOnion.sln b/MagicOnion.sln index 0f8d2c22f..32166e40b 100644 --- a/MagicOnion.sln +++ b/MagicOnion.sln @@ -101,7 +101,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Serialization.Me EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Serialization.MemoryPack.Tests", "tests\MagicOnion.Serialization.MemoryPack.Tests\MagicOnion.Serialization.MemoryPack.Tests.csproj", "{A5A4ED92-71AD-410E-9310-A8BF48D32126}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicOnion.Server.Redis.Tests", "tests\MagicOnion.Server.Redis.Tests\MagicOnion.Server.Redis.Tests.csproj", "{95C3B040-BD5A-4A80-B5D4-26CAA21B4829}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Server.Redis.Tests", "tests\MagicOnion.Server.Redis.Tests\MagicOnion.Server.Redis.Tests.csproj", "{95C3B040-BD5A-4A80-B5D4-26CAA21B4829}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicOnion.Client.SourceGenerator", "src\MagicOnion.Client.SourceGenerator\MagicOnion.Client.SourceGenerator.csproj", "{7130EC5B-C987-487A-B319-E91B6D03F5BF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGenerator.Tests", "tests\MagicOnion.Client.SourceGenerator.Tests\MagicOnion.Client.SourceGenerator.Tests.csproj", "{632C8D1B-3293-4D02-9ED1-0CB191619334}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -229,6 +233,14 @@ Global {95C3B040-BD5A-4A80-B5D4-26CAA21B4829}.Debug|Any CPU.Build.0 = Debug|Any CPU {95C3B040-BD5A-4A80-B5D4-26CAA21B4829}.Release|Any CPU.ActiveCfg = Release|Any CPU {95C3B040-BD5A-4A80-B5D4-26CAA21B4829}.Release|Any CPU.Build.0 = Release|Any CPU + {7130EC5B-C987-487A-B319-E91B6D03F5BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7130EC5B-C987-487A-B319-E91B6D03F5BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7130EC5B-C987-487A-B319-E91B6D03F5BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7130EC5B-C987-487A-B319-E91B6D03F5BF}.Release|Any CPU.Build.0 = Release|Any CPU + {632C8D1B-3293-4D02-9ED1-0CB191619334}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {632C8D1B-3293-4D02-9ED1-0CB191619334}.Debug|Any CPU.Build.0 = Debug|Any CPU + {632C8D1B-3293-4D02-9ED1-0CB191619334}.Release|Any CPU.ActiveCfg = Release|Any CPU + {632C8D1B-3293-4D02-9ED1-0CB191619334}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -269,6 +281,8 @@ Global {56C784C7-3F18-4443-B7B0-03607ED14308} = {1987061F-8970-4018-8D58-6932961C9EB4} {A5A4ED92-71AD-410E-9310-A8BF48D32126} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} {95C3B040-BD5A-4A80-B5D4-26CAA21B4829} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} + {7130EC5B-C987-487A-B319-E91B6D03F5BF} = {1987061F-8970-4018-8D58-6932961C9EB4} + {632C8D1B-3293-4D02-9ED1-0CB191619334} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D5B2E7E3-B727-40A1-BE68-7BAC9B9DE2FE} diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj new file mode 100644 index 000000000..e4c1864e2 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -0,0 +1,25 @@ + + + + netstandard2.0 + + latest + enable + enable + Nullable + + + true + cs + + + + + + + + + + + + diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs new file mode 100644 index 000000000..084db6775 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -0,0 +1,44 @@ +using MagicOnion.Generator; +using MagicOnion.Generator.Internal; +using Microsoft.CodeAnalysis; +using System.Linq; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace MagicOnion.Client.SourceGenerator; + +[Generator(LanguageNames.CSharp)] +public class MagicOnionClientSourceGenerator : ISourceGenerator +{ + const string OptionsAttributeName = "MagicOnionClientSourceGeneratorOptions"; + + public void Initialize(GeneratorInitializationContext context) + { + context.RegisterForSyntaxNotifications(() => new SyntaxContextReceiver()); + } + + public void Execute(GeneratorExecutionContext context) + { + var @namespace = "MagicOnion"; + var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance, context.CancellationToken); + var outputs = compiler.GenerateAsync(context.Compilation, "MagicOnionClient.g.cs", + disableAutoRegister: false, + @namespace: @namespace, + userDefinedFormattersNamespace: "MessagePack.Formatter", + serializerType: SerializerType.MessagePack + ).GetAwaiter().GetResult(); + + var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxContextReceiver!; + + foreach (var output in outputs) + { + context.AddSource(output.Path, output.Source); + } + } + + class SyntaxContextReceiver : ISyntaxContextReceiver + { + public void OnVisitSyntaxNode(GeneratorSyntaxContext context) + { + } + } +} diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs index 5ac5c664b..4b055af79 100644 --- a/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs @@ -10,8 +10,9 @@ namespace MagicOnion.Generator.CodeAnalysis; public class MethodCollector { readonly IMagicOnionGeneratorLogger logger; + readonly CancellationToken cancellationToken; - public MethodCollector(IMagicOnionGeneratorLogger logger = null) + public MethodCollector(IMagicOnionGeneratorLogger logger = null, CancellationToken cancellationToken = default) { this.logger = logger ?? MagicOnionGeneratorNullLogger.Instance; } diff --git a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs b/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs index 1de96a1c5..b9d261724 100644 --- a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs +++ b/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs @@ -10,6 +10,7 @@ using MagicOnion.Generator.CodeGen.Extensions; using MagicOnion.Generator.Internal; using System.Collections.Generic; +using Microsoft.CodeAnalysis; namespace MagicOnion.Generator; @@ -41,16 +42,53 @@ public async Task GenerateFileAsync( string userDefinedFormattersNamespace, SerializerType serializerType) { - // Prepare args - var namespaceDot = string.IsNullOrWhiteSpace(@namespace) ? string.Empty : @namespace + "."; var conditionalSymbols = conditionalSymbol?.Split(',') ?? Array.Empty(); // Generator Start... logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:Input: {input}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:Output: {output}"); + logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:ConditionalSymbol: {conditionalSymbol}"); + + var sw = Stopwatch.StartNew(); + logger.Information("Project Compilation Start:" + input); + var compilation = await PseudoCompilation.CreateFromProjectAsync(new[] { input }, conditionalSymbols, logger, cancellationToken); + logger.Information("Project Compilation Complete:" + sw.Elapsed.ToString()); + + var outputs = await GenerateAsync(compilation, Path.GetFileName(output), disableAutoRegister, @namespace, userDefinedFormattersNamespace, serializerType); + + sw.Restart(); + logger.Information("Writing generated codes"); + if (Path.GetExtension(output) == ".cs") + { + Output(output, outputs[0].Source); + } + else + { + foreach (var o in outputs) + { + Output(o.Path, o.Source); + } + } + logger.Information("Writing generated codes Complete:" + sw.Elapsed.ToString()); + } + + + public async Task> GenerateAsync( + Compilation compilation, + string generatedFileNameBase, + bool disableAutoRegister, + string @namespace, + string userDefinedFormattersNamespace, + SerializerType serializerType + ) + { + var outputs = new List<(string Path, string Source)>(); + + // Prepare args + var namespaceDot = string.IsNullOrWhiteSpace(@namespace) ? string.Empty : @namespace + "."; + + // Generator Start... logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:DisableAutoRegister: {disableAutoRegister}"); logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:Namespace: {@namespace}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:ConditionalSymbol: {conditionalSymbol}"); logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:UserDefinedFormattersNamespace: {userDefinedFormattersNamespace}"); logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:SerializerType: {serializerType}"); logger.Trace($"[{nameof(MagicOnionCompiler)}] Assembly version: {typeof(MagicOnionCompiler).Assembly.GetCustomAttribute().InformationalVersion}"); @@ -84,23 +122,24 @@ public async Task GenerateFileAsync( }; var sw = Stopwatch.StartNew(); - logger.Information("Project Compilation Start:" + input); - var compilation = await PseudoCompilation.CreateFromProjectAsync(new[] { input }, conditionalSymbols, logger, cancellationToken); - logger.Information("Project Compilation Complete:" + sw.Elapsed.ToString()); sw.Restart(); logger.Information("Collect services and methods Start"); - var collector = new MethodCollector(logger); + var collector = new MethodCollector(logger, cancellationToken); var serviceCollection = collector.Collect(compilation); logger.Information("Collect services and methods Complete:" + sw.Elapsed.ToString()); - + + cancellationToken.ThrowIfCancellationRequested(); + sw.Restart(); logger.Information("Collect serialization information Start"); var serializationInfoCollector = new SerializationInfoCollector(logger, serialization.Mapper); var serializationInfoCollection = serializationInfoCollector.Collect(serviceCollection); logger.Information("Collect serialization information Complete:" + sw.Elapsed.ToString()); - logger.Information("Output Generation Start"); + cancellationToken.ThrowIfCancellationRequested(); + + logger.Information("Code Generation Start"); sw.Restart(); var registerTemplate = new RegisterTemplate @@ -114,51 +153,27 @@ public async Task GenerateFileAsync( var formatterCodeGenContext = new SerializationFormatterCodeGenContext(serialization.Namespace, namespaceDot + "Formatters", serialization.InitializerName, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); var resolverTexts = serialization.Generator.Build(formatterCodeGenContext); - if (Path.GetExtension(output) == ".cs") - { - var enums = serializationInfoCollection.Enums - .GroupBy(x => x.Namespace) - .OrderBy(x => x.Key) - .ToArray(); - - var clientTexts = StaticMagicOnionClientGenerator.Build(serviceCollection.Services); - var hubTexts = StaticStreamingHubClientGenerator.Build(serviceCollection.Hubs); - - var sb = new StringBuilder(); - sb.AppendLine("// "); - sb.AppendLine(registerTemplate.TransformText()); - sb.AppendLine(resolverTexts); - foreach (var item in enums) - { - sb.AppendLine(serialization.EnumFormatterGenerator(item)); - } + cancellationToken.ThrowIfCancellationRequested(); - sb.AppendLine(clientTexts); - sb.AppendLine(hubTexts); - Output(output, sb.ToString()); - } - else - { - Output(NormalizePath(output, registerTemplate.Namespace, "MagicOnionInitializer"), WithAutoGenerated(registerTemplate.TransformText())); - Output(NormalizePath(output, formatterCodeGenContext.Namespace, formatterCodeGenContext.InitializerName), WithAutoGenerated(resolverTexts)); + outputs.Add((GeneratePathFromNamespaceAndTypeName(registerTemplate.Namespace, "MagicOnionInitializer"), WithAutoGenerated(registerTemplate.TransformText()))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(formatterCodeGenContext.Namespace, formatterCodeGenContext.InitializerName), WithAutoGenerated(resolverTexts))); - foreach (var enumSerializationInfo in serializationInfoCollection.Enums) - { - Output(NormalizePath(output, namespaceDot + "Formatters", enumSerializationInfo.FormatterName), WithAutoGenerated(serialization.EnumFormatterGenerator(new []{ enumSerializationInfo }))); - } + foreach (var enumSerializationInfo in serializationInfoCollection.Enums) + { + outputs.Add((GeneratePathFromNamespaceAndTypeName(namespaceDot + "Formatters", enumSerializationInfo.FormatterName), WithAutoGenerated(serialization.EnumFormatterGenerator(new []{ enumSerializationInfo })))); + } - foreach (var service in serviceCollection.Services) - { - var x = StaticMagicOnionClientGenerator.Build(new[] { service }); - Output(NormalizePath(output, service.ServiceType.Namespace, service.GetClientName()), WithAutoGenerated(x)); - } + foreach (var service in serviceCollection.Services) + { + var x = StaticMagicOnionClientGenerator.Build(new[] { service }); + outputs.Add((GeneratePathFromNamespaceAndTypeName(service.ServiceType.Namespace, service.GetClientName()), WithAutoGenerated(x))); + } - foreach (var hub in serviceCollection.Hubs) - { - var x = StaticStreamingHubClientGenerator.Build(new [] { hub }); - Output(NormalizePath(output, hub.ServiceType.Namespace, hub.GetClientName()), WithAutoGenerated(x)); - } + foreach (var hub in serviceCollection.Hubs) + { + var x = StaticStreamingHubClientGenerator.Build(new [] { hub }); + outputs.Add((GeneratePathFromNamespaceAndTypeName(hub.ServiceType.Namespace, hub.GetClientName()), WithAutoGenerated(x))); } if (serviceCollection.Services.Count == 0 && serviceCollection.Hubs.Count == 0) @@ -166,12 +181,14 @@ public async Task GenerateFileAsync( logger.Information("Generated result is empty, unexpected result?"); } - logger.Information("Output Generation Complete:" + sw.Elapsed.ToString()); + logger.Information("Code Generation Complete:" + sw.Elapsed.ToString()); + + return outputs.OrderBy(x => x.Path).ToArray(); } - static string NormalizePath(string dir, string ns, string className) + static string GeneratePathFromNamespaceAndTypeName(string ns, string className) { - return Path.Combine(dir, $"{ns}_{className}".Replace(".", "_").Replace("global::", string.Empty) + ".cs"); + return $"{ns}_{className}".Replace(".", "_").Replace("global::", string.Empty) + ".cs"; } static string WithAutoGenerated(string s) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs new file mode 100644 index 000000000..9e09c5324 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs @@ -0,0 +1,199 @@ +using MagicOnion.Client.SourceGenerator.Tests.Verifiers; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public class GenerateServiceTest +{ + [Fact] + public async Task Return_UnaryResultNonGeneric() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult A(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_UnaryResultOfT() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult A(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_UnaryResultOfValueType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult A(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_UnaryResultOfRefType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult A(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Invalid_Return_TaskOfUnaryResultOfT() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + Task> A(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_StreamingResult() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + using System.Threading.Tasks; + + namespace TempProject + { + public interface IMyService : IService + { + Task> ClientStreamingAsync(); + Task> ServerStreamingAsync(); + Task> DuplexStreamingAsync(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Invalid_Return_NonGenerics() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + int A(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Invalid_Return_NonSupportedUnaryResultOfT() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult> A(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Invalid_Return_RawStreaming_NonTask() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + ClientStreamingResult ClientStreamingAsync(); + ServerStreamingResult ServerStreamingAsync(); + DuplexStreamingResult DuplexStreamingAsync(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs new file mode 100644 index 000000000..de422b29d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs @@ -0,0 +1,353 @@ +using MagicOnion.Client.SourceGenerator.Tests.Verifiers; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public class GenerateStreamingHubTest +{ + [Fact] + public async Task Complex() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void OnMessage(); + void OnMessage2(MyObject a); + void OnMessage3(MyObject a, string b, int c); + + } + public interface IMyHub : IStreamingHub + { + Task A(); + Task B(MyObject a); + Task C(MyObject a, string b); + Task D(MyObject a, string b, int c); + Task E(MyObject a, string b, int c); + } + + [MessagePackObject] + public class MyObject + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_Parameter_Zero() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void OnMessage(); + } + public interface IMyHub : IStreamingHub + { + Task A(MyObject a); + } + + [MessagePackObject] + public class MyObject + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_Parameter_One() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void OnMessage(MyObject arg0); + } + public interface IMyHub : IStreamingHub + { + Task A(MyObject a); + } + + [MessagePackObject] + public class MyObject + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_Parameter_Many() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void OnMessage(MyObject arg0, int arg1, string arg2); + } + public interface IMyHub : IStreamingHub + { + Task A(MyObject a); + } + + [MessagePackObject] + public class MyObject + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_Task() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task A(MyObject a); + } + + [MessagePackObject] + public class MyObject + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_TaskOfT() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task A(MyObject a); + } + + [MessagePackObject] + public class MyObject + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_ValueTask() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + ValueTask A(MyObject a); + } + + [MessagePackObject] + public class MyObject + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_ValueTaskOfT() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + ValueTask A(MyObject a); + } + + [MessagePackObject] + public class MyObject + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Invalid_Return_Void() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + void A(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Invalid_HubReceiver_ReturnsNotVoid() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + Task B(); + } + public interface IMyHub : IStreamingHub + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameter_Zero() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task A(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameter_One() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task A(string arg0); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameter_Many() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task A(string arg0, int arg1, bool arg2); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs new file mode 100644 index 000000000..4d87f43fe --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs @@ -0,0 +1,80 @@ +using MagicOnion.Client.SourceGenerator.Tests.Verifiers; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public class GenerateTest +{ + [Fact] + public async Task Test1() + { + var source = """ + using MagicOnion; + + namespace MyApplication1; + + public interface IGreeterService : IService + { + UnaryResult HelloAsync(string name, int age); + UnaryResult PingAsync(); + UnaryResult CanGreetAsync(); + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task ImplicitUsings_PropertyGroup_Enable() + { + var sources = new [] + { + ("Usings.cs", + """ + // ImplicitUsings: Microsoft.NET.Sdk + global using global::System; + global using global::System.Collections.Generic; + global using global::System.IO; + global using global::System.Linq; + global using global::System.Net.Http; + global using global::System.Threading; + global using global::System.Threading.Tasks; + """), + ("IMyService.cs", + """ + using MagicOnion; + using MessagePack; + + namespace MyNamespace; + + public interface IMyService : IService + { + UnaryResult A(Int32 arg0, IReadOnlyList arg1, FileMode arg2, ILookup arg3, ClientCertificateOption arg4, ApartmentState arg5, TaskCreationOptions arg6); + } + """ + ), + }; + await MagicOnionSourceGeneratorVerifier.RunAsync(sources); + } + + //[Fact] + //public async Task ImplicitUsings_PropertyGroup_Disable() + //{ + // var sources = new [] + // { + // ("IMyService.cs", + // """ + // using MagicOnion; + // using MessagePack; + // + // namespace MyNamespace; + // + // public interface IMyService : IService + // { + // UnaryResult A(Int32 arg0, IReadOnlyList arg1, FileMode arg2, ILookup arg3, ClientCertificateOption arg4, ApartmentState arg5, TaskCreationOptions arg6); + // } + // """ + // ), + // }; + // await MagicOnionSourceGeneratorVerifier.RunAsync(sources); + //} +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateWithIfDirectiveTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateWithIfDirectiveTest.cs new file mode 100644 index 000000000..e5a2bb467 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateWithIfDirectiveTest.cs @@ -0,0 +1,67 @@ +using MagicOnion.Client.SourceGenerator.Tests.Verifiers; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public class GenerateWithIfDirectiveTest +{ + [Fact] + public async Task Skip_Generation_StreamingHub_Interface() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void OnMessage(int a); + } + public interface IMyHub : IStreamingHub + { + Task A(int a); + } + + #if DEBUG + public interface IMyDebugHub : IStreamingHub + { + Task A(int a); + } + #endif + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Skip_Generation_Service_Interface() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult A(); + } + + #if DEBUG + public interface IMyServiceForDebug : IService + { + UnaryResult A(); + } + #endif + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj new file mode 100644 index 000000000..caac74e20 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj @@ -0,0 +1,38 @@ + + + + + net6.0 + latest + enable + enable + + false + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..5e0445213 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.cs new file mode 100644 index 000000000..46bf03d4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.cs @@ -0,0 +1,62 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker ClientStreamingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker ServerStreamingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker DuplexStreamingAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.ClientStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.ClientStreaming, "IMyService", "ClientStreamingAsync", serializerProvider); + this.ServerStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.ServerStreaming, "IMyService", "ServerStreamingAsync", serializerProvider); + this.DuplexStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.DuplexStreaming, "IMyService", "DuplexStreamingAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::System.Threading.Tasks.Task> ClientStreamingAsync() + => this.core.ClientStreamingAsync.InvokeClientStreaming(this, "IMyService/ClientStreamingAsync"); + public global::System.Threading.Tasks.Task> ServerStreamingAsync() + => this.core.ServerStreamingAsync.InvokeServerStreaming(this, "IMyService/ServerStreamingAsync", global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> DuplexStreamingAsync() + => this.core.DuplexStreamingAsync.InvokeDuplexStreaming(this, "IMyService/DuplexStreamingAsync"); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..f789a1a02 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.cs new file mode 100644 index 000000000..f0df37b11 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A() + => this.core.A.InvokeUnaryNonGeneric(this, "IMyService/A", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..5e0445213 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.cs new file mode 100644 index 000000000..76aa922de --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..2b2043c1c --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.cs new file mode 100644 index 000000000..851646aa6 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..2e9f1f456 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.cs new file mode 100644 index 000000000..5d5e39ec9 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..4c4301714 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, + {typeof(global::MagicOnion.DynamicArgumentTuple), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::TempProject.MyObject), default(global::System.String), default(global::System.Int32)); + case 1: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::TempProject.MyObject), default(global::System.String)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.cs new file mode 100644 index 000000000..55eaade7c --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.cs @@ -0,0 +1,123 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A() + => base.WriteMessageWithResponseAsync(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task B(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-955516027, a); + public global::System.Threading.Tasks.Task C(global::TempProject.MyObject a, global::System.String b) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-972293646, new global::MagicOnion.DynamicArgumentTuple(a, b)); + public global::System.Threading.Tasks.Task D(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1056181741, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); + public global::System.Threading.Tasks.Task E(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + => base.WriteMessageWithResponseAsync, global::System.Int32>(-1072959360, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A() + => parent.WriteMessageFireAndForgetAsync(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task B(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-955516027, a); + public global::System.Threading.Tasks.Task C(global::TempProject.MyObject a, global::System.String b) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-972293646, new global::MagicOnion.DynamicArgumentTuple(a, b)); + public global::System.Threading.Tasks.Task D(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1056181741, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); + public global::System.Threading.Tasks.Task E(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + => parent.WriteMessageFireAndForgetAsync, global::System.Int32>(-1072959360, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1262822265: // Void OnMessage() + { + var value = base.Deserialize(data); + receiver.OnMessage(); + } + break; + case 925462767: // Void OnMessage2(global::TempProject.MyObject a) + { + var value = base.Deserialize(data); + receiver.OnMessage2(value); + } + break; + case 908685148: // Void OnMessage3(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + { + var value = base.Deserialize>(data); + receiver.OnMessage3(value.Item1, value.Item2, value.Item3); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A() + base.SetResultForResponse(taskCompletionSource, data); + break; + case -955516027: // Task B(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -972293646: // Task C(global::TempProject.MyObject a, global::System.String b) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -1056181741: // Task D(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -1072959360: // Task E(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..76d1949ae --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::TempProject.MyObject), default(global::System.Int32), default(global::System.String)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.cs new file mode 100644 index 000000000..a9a5aff6d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1262822265: // Void OnMessage(global::TempProject.MyObject arg0, global::System.Int32 arg1, global::System.String arg2) + { + var value = base.Deserialize>(data); + receiver.OnMessage(value.Item1, value.Item2, value.Item3); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..592c33fe5 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.cs new file mode 100644 index 000000000..6406f6f7b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1262822265: // Void OnMessage(global::TempProject.MyObject arg0) + { + var value = base.Deserialize(data); + receiver.OnMessage(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..592c33fe5 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.cs new file mode 100644 index 000000000..c80cee5f8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1262822265: // Void OnMessage() + { + var value = base.Deserialize(data); + receiver.OnMessage(); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..a8fb9296d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32), default(global::System.Boolean)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.cs new file mode 100644 index 000000000..7af27938a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::System.String arg0, global::System.Int32 arg1, global::System.Boolean arg2) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1005848884, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::System.String arg0, global::System.Int32 arg1, global::System.Boolean arg2) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1005848884, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::System.String arg0, global::System.Int32 arg1, global::System.Boolean arg2) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..5e0445213 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.cs new file mode 100644 index 000000000..1b038c289 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::System.String arg0) + => base.WriteMessageWithResponseAsync(-1005848884, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::System.String arg0) + => parent.WriteMessageFireAndForgetAsync(-1005848884, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::System.String arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..f789a1a02 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.cs new file mode 100644 index 000000000..7f4ba0f66 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A() + => base.WriteMessageWithResponseAsync(-1005848884, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A() + => parent.WriteMessageFireAndForgetAsync(-1005848884, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A() + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..592c33fe5 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.cs new file mode 100644 index 000000000..059399f4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..66c8eca10 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.cs new file mode 100644 index 000000000..8a3868c1a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..592c33fe5 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.cs new file mode 100644 index 000000000..23cbe70b6 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) + => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(-1005848884, a)); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) + => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(-1005848884, a)); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // ValueTask A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..66c8eca10 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.cs new file mode 100644 index 000000000..ff276ef5a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) + => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(-1005848884, a)); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) + => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(-1005848884, a)); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // ValueTask A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..8c8361ed2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyNamespace.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyNamespace.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..f7091288a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,98 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::ILookup), 0 }, + {typeof(global::IReadOnlyList), 1 }, + {typeof(global::MagicOnion.DynamicArgumentTuple, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>), 2 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatter.ILookupFormatter(); + case 1: return new global::MessagePack.Formatter.IReadOnlyListFormatter(); + case 2: return new global::MagicOnion.DynamicArgumentTupleFormatter, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>(default(global::Int32), default(global::IReadOnlyList), default(global::FileMode), default(global::ILookup), default(global::ClientCertificateOption), default(global::ApartmentState), default(global::TaskCreationOptions)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MyNamespace_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MyNamespace_MyServiceClient.cs new file mode 100644 index 000000000..1f65f72b2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MyNamespace_MyServiceClient.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MyNamespace +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyNamespace.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>, global::MessagePack.Nil> A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A(global::Int32 arg0, global::IReadOnlyList arg1, global::FileMode arg2, global::ILookup arg3, global::ClientCertificateOption arg4, global::ApartmentState arg5, global::TaskCreationOptions arg6) + => this.core.A.InvokeUnary(this, "IMyService/A", new global::MagicOnion.DynamicArgumentTuple, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.cs new file mode 100644 index 000000000..bd632954b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class ApartmentStateFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::System.Threading.ApartmentState value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.Threading.ApartmentState Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::System.Threading.ApartmentState)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.cs new file mode 100644 index 000000000..ad23fb208 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class ClientCertificateOptionFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::System.Net.Http.ClientCertificateOption value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.Net.Http.ClientCertificateOption Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::System.Net.Http.ClientCertificateOption)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.cs new file mode 100644 index 000000000..21621beae --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class FileModeFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::System.IO.FileMode value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.IO.FileMode Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::System.IO.FileMode)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.cs new file mode 100644 index 000000000..89c80da43 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class TaskCreationOptionsFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::System.Threading.Tasks.TaskCreationOptions value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.Threading.Tasks.TaskCreationOptions Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::System.Threading.Tasks.TaskCreationOptions)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..8c8361ed2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyNamespace.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyNamespace.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..8dffc94ac --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,105 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(7) + { + {typeof(global::MagicOnion.DynamicArgumentTuple, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>), 0 }, + {typeof(global::System.Collections.Generic.IReadOnlyList), 1 }, + {typeof(global::System.Linq.ILookup), 2 }, + {typeof(global::System.IO.FileMode), 3 }, + {typeof(global::System.Net.Http.ClientCertificateOption), 4 }, + {typeof(global::System.Threading.ApartmentState), 5 }, + {typeof(global::System.Threading.Tasks.TaskCreationOptions), 6 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>(default(global::System.Int32), default(global::System.Collections.Generic.IReadOnlyList), default(global::System.IO.FileMode), default(global::System.Linq.ILookup), default(global::System.Net.Http.ClientCertificateOption), default(global::System.Threading.ApartmentState), default(global::System.Threading.Tasks.TaskCreationOptions)); + case 1: return new global::MessagePack.Formatters.InterfaceReadOnlyListFormatter(); + case 2: return new global::MessagePack.Formatters.InterfaceLookupFormatter(); + case 3: return new MagicOnion.Formatters.FileModeFormatter(); + case 4: return new MagicOnion.Formatters.ClientCertificateOptionFormatter(); + case 5: return new MagicOnion.Formatters.ApartmentStateFormatter(); + case 6: return new MagicOnion.Formatters.TaskCreationOptionsFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.cs new file mode 100644 index 000000000..31b4f6169 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MyNamespace +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyNamespace.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>, global::MessagePack.Nil> A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A(global::System.Int32 arg0, global::System.Collections.Generic.IReadOnlyList arg1, global::System.IO.FileMode arg2, global::System.Linq.ILookup arg3, global::System.Net.Http.ClientCertificateOption arg4, global::System.Threading.ApartmentState arg5, global::System.Threading.Tasks.TaskCreationOptions arg6) + => this.core.A.InvokeUnary(this, "IMyService/A", new global::MagicOnion.DynamicArgumentTuple, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d013f540a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..466082a12 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MyApplication1_GreeterServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MyApplication1_GreeterServiceClient.cs new file mode 100644 index 000000000..6adbc49ec --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MyApplication1_GreeterServiceClient.cs @@ -0,0 +1,62 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MyApplication1 +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker PingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker CanGreetAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + this.PingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "PingAsync", serializerProvider); + this.CanGreetAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "CanGreetAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + public global::MagicOnion.UnaryResult PingAsync() + => this.core.PingAsync.InvokeUnaryNonGeneric(this, "IGreeterService/PingAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult CanGreetAsync() + => this.core.CanGreetAsync.InvokeUnary(this, "IGreeterService/CanGreetAsync", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..2b2043c1c --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.cs new file mode 100644 index 000000000..851646aa6 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs new file mode 100644 index 000000000..2b2043c1c --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.cs new file mode 100644 index 000000000..0e29d59b7 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::System.Int32 a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::System.Int32 a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1262822265: // Void OnMessage(global::System.Int32 a) + { + var value = base.Deserialize(data); + receiver.OnMessage(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::System.Int32 a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Usings.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Usings.cs new file mode 100644 index 000000000..91743bbbb --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Usings.cs @@ -0,0 +1,2 @@ +global using Xunit; +global using FluentAssertions; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs new file mode 100644 index 000000000..4c0b8e52a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -0,0 +1,132 @@ +#define WRITE_EXPECTED + +// https://github.com/MessagePack-CSharp/MessagePack-CSharp/blob/develop/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier%601%2BTest.cs +// https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#unit-testing-of-generators + +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Text; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.Testing; +using Microsoft.CodeAnalysis.Testing.Verifiers; +using Microsoft.CodeAnalysis.Text; +using VerifyCS = MagicOnion.Client.SourceGenerator.Tests.Verifiers.MagicOnionSourceGeneratorVerifier; + +namespace MagicOnion.Client.SourceGenerator.Tests.Verifiers; + +internal class MagicOnionSourceGeneratorVerifier +{ + public static async Task RunAsync(string testSourceCode, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) + { + if (string.IsNullOrEmpty(testSourceCode)) throw new ArgumentNullException(nameof(testSourceCode)); + if (string.IsNullOrEmpty(testFile)) throw new ArgumentNullException(nameof(testFile)); + if (string.IsNullOrEmpty(testMethod)) throw new ArgumentNullException(nameof(testMethod)); + + await RunAsync(new[] { ("Source.cs", testSourceCode) }, testFile, testMethod); + } + public static async Task RunAsync(IEnumerable<(string Path, string Content)> testSourceCodes, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) + { + if (testSourceCodes is null) throw new ArgumentNullException(nameof(testSourceCodes)); + if (string.IsNullOrEmpty(testFile)) throw new ArgumentNullException(nameof(testFile)); + if (string.IsNullOrEmpty(testMethod)) throw new ArgumentNullException(nameof(testMethod)); + + var test = new VerifyCS.Test(testFile, testMethod) + { + TestState = + { + }, + }; + test.TestState.Sources.AddRange(testSourceCodes.Select(x => (x.Path, SourceText.From(x.Content, Encoding.UTF8, SourceHashAlgorithm.Sha1)))); + await test.RunAsync(); + } + + internal class Test : CSharpSourceGeneratorTest + { + readonly string testFile; + readonly string testMethod; + + public Test(string testFile, string testMethod) + { + this.testFile = testFile; + this.testMethod = testMethod; + this.ReferenceAssemblies = ReferenceAssemblies.Net.Net60; + this.AddAdditionalReferences(); + +#if WRITE_EXPECTED + TestBehaviors |= TestBehaviors.SkipGeneratedSourcesCheck; +#endif + } + + void AddAdditionalReferences() + { + // MagicOnion.Abstractions + this.TestState.AdditionalReferences.Add(typeof(MagicOnion.UnaryResult).Assembly); + // MagicOnion.Client + this.TestState.AdditionalReferences.Add(typeof(MagicOnion.Client.MagicOnionClient).Assembly); + // MagicOnion.Shared + this.TestState.AdditionalReferences.Add(typeof(MagicOnion.MagicOnionMarshallers).Assembly); + // MessagePack + this.TestState.AdditionalReferences.Add(typeof(MessagePack.Formatters.IMessagePackFormatter).Assembly); + // MessagePack.Annotations + this.TestState.AdditionalReferences.Add(typeof(MessagePack.MessagePackObjectAttribute).Assembly); + // Grpc.Core.Api + this.TestState.AdditionalReferences.Add(typeof(Grpc.Core.AsyncUnaryCall<>).Assembly); + // Grpc.Net.Client + this.TestState.AdditionalReferences.Add(typeof(Grpc.Net.Client.GrpcChannel).Assembly); + } + + void AddGeneratedReferenceSources() + { + var prefix = $"{typeof(Test).Assembly.GetName().Name}.Resources.{Path.GetFileNameWithoutExtension(testFile)}.{testMethod}."; + + foreach (var resName in typeof(Test).Assembly.GetManifestResourceNames()) + { + if (!resName.StartsWith(prefix)) continue; + + using var stream = typeof(Test).Assembly.GetManifestResourceStream(resName) ?? throw new InvalidOperationException(); + using var reader = new StreamReader(stream); + var source = reader.ReadToEnd(); + TestState.GeneratedSources.Add((typeof(MagicOnion.Client.SourceGenerator.MagicOnionClientSourceGenerator), resName.Substring(prefix.Length), SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha1))); + } + } + + protected override Task RunImplAsync(CancellationToken cancellationToken) + { + AddGeneratedReferenceSources(); + return base.RunImplAsync(cancellationToken); + } + + protected override async Task GetProjectCompilationAsync(Project project, IVerifier verifier, CancellationToken cancellationToken) + { + var compilation = await base.GetProjectCompilationAsync(project, verifier, cancellationToken); + var resourceDirectory = Path.Combine(Path.GetDirectoryName(testFile)!, "Resources", Path.GetFileNameWithoutExtension(testFile), testMethod); + + foreach (var syntaxTree in compilation.SyntaxTrees.Skip(project.DocumentIds.Count)) + { + WriteTreeToDiskIfNecessary(syntaxTree, resourceDirectory, ""); + } + + return compilation; + } + + protected override IEnumerable GetSourceGenerators() + { + yield return new MagicOnionClientSourceGenerator(); + } + + [Conditional("WRITE_EXPECTED")] + static void WriteTreeToDiskIfNecessary(SyntaxTree tree, string resourceDirectory, string fileNamePrefix) + { + if (tree.Encoding is null) + { + throw new ArgumentException("Syntax tree encoding was not specified"); + } + + var name = fileNamePrefix + Path.GetFileName(tree.FilePath); + var filePath = Path.Combine(resourceDirectory, name); + Directory.CreateDirectory(resourceDirectory); + File.WriteAllText(filePath, tree.GetText().ToString(), tree.Encoding); + } + } +} From 0ea71e319f0d030e9b1895568d57db1801e5ae53 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 4 Oct 2023 18:35:00 +0900 Subject: [PATCH 02/66] WIP --- .../MagicOnionClientSourceGenerator.cs | 2 +- .../MagicOnionCompiler.cs | 2 +- .../GenerateGenericsTest.cs | 648 ++++++++++++++++++ .../GenerateRawStreamingTest.cs | 29 + ...cOnion.Client.SourceGenerator.Tests.csproj | 3 + .../MagicOnion_MagicOnionInitializer.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 121 ++++ .../TempProject_MyServiceClient.g.cs | 94 +++ .../MagicOnion_MagicOnionInitializer.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 96 +++ .../TempProject_MyServiceClient.g.cs | 62 ++ .../MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 22 +- .../TempProject_MyServiceClient.g.cs | 70 ++ .../MagicOnion_MagicOnionInitializer.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 +++ .../TempProject_MyServiceClient.g.cs} | 12 +- .../MagicOnion_MagicOnionInitializer.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 +++ .../TempProject_MyServiceClient.g.cs | 58 ++ .../MagicOnion_MagicOnionInitializer.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 +++ .../TempProject_MyServiceClient.g.cs | 54 ++ .../MagicOnion_MagicOnionInitializer.g.cs} | 4 +- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 102 +++ .../TempProject_MyServiceClient.g.cs | 62 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 +++ .../TempProject_MyServiceClient.g.cs | 54 ++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 91 +++ .../TempProject_MyServiceClient.g.cs | 54 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 +++ .../Return/TempProject_MyServiceClient.g.cs | 58 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 +++ .../TempProject_MyServiceClient.g.cs | 70 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 +++ .../TempProject_MyServiceClient.g.cs | 54 ++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 88 +++ .../TempProject_MyServiceClient.g.cs | 54 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 +++ .../TempProject_MyServiceClient.g.cs | 58 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 +++ .../TempProject_MyServiceClient.g.cs | 54 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 +++ .../TempProject_MyServiceClient.g.cs | 58 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 102 +++ .../TempProject_MyServiceClient.g.cs | 62 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 +++ .../TempProject_MyServiceClient.g.cs | 54 ++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 91 +++ .../TempProject_MyServiceClient.g.cs | 54 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 .../TempProject_MyServiceClient.g.cs} | 0 .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 .../TempProject_MyServiceClient.g.cs | 62 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...nt.cs => TempProject_MyServiceClient.g.cs} | 0 .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...nt.cs => TempProject_MyServiceClient.g.cs} | 0 .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...nt.cs => TempProject_MyServiceClient.g.cs} | 0 .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...nt.cs => TempProject_MyServiceClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 83 +++ ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 ...n_Formatters_ApartmentStateFormatter.g.cs} | 0 ...ers_ClientCertificateOptionFormatter.g.cs} | 0 ...icOnion_Formatters_FileModeFormatter.g.cs} | 0 ...matters_TaskCreationOptionsFormatter.g.cs} | 0 .../MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...nt.cs => MyNamespace_MyServiceClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ... MyApplication1_GreeterServiceClient.g.cs} | 0 .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++ ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...nt.cs => TempProject_MyServiceClient.g.cs} | 0 ... => MagicOnion_MagicOnionInitializer.g.cs} | 0 ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 0 ...Client.cs => TempProject_MyHubClient.g.cs} | 0 .../MagicOnionSourceGeneratorVerifier.cs | 2 +- 133 files changed, 5532 insertions(+), 26 deletions(-) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/GenerateRawStreamingTest.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.cs => GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.cs => GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.cs => GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_Resolvers_MagicOnionResolver.cs => GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs} (62%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.cs => GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateTest/ImplicitUsings_PropertyGroup_Disable/MyNamespace_MyServiceClient.cs => GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs} (55%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.cs => GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.cs => GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.cs => GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs} (96%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.cs => GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.cs => GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/{Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.cs => Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/{TempProject_MyServiceClient.cs => TempProject_MyServiceClient.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs => GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/{TempProject_MyServiceClient.cs => TempProject_MyServiceClient.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/{TempProject_MyServiceClient.cs => TempProject_MyServiceClient.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/{TempProject_MyServiceClient.cs => TempProject_MyServiceClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{MagicOnion_Formatters_ApartmentStateFormatter.cs => MagicOnion_Formatters_ApartmentStateFormatter.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{MagicOnion_Formatters_ClientCertificateOptionFormatter.cs => MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{MagicOnion_Formatters_FileModeFormatter.cs => MagicOnion_Formatters_FileModeFormatter.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{MagicOnion_Formatters_TaskCreationOptionsFormatter.cs => MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/{ImplicitUsings_PropertyGroup_Disable/MagicOnion_MagicOnionInitializer.cs => ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{MyNamespace_MyServiceClient.cs => MyNamespace_MyServiceClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/{MyApplication1_GreeterServiceClient.cs => MyApplication1_GreeterServiceClient.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/{TempProject_MyServiceClient.cs => TempProject_MyServiceClient.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/{MagicOnion_MagicOnionInitializer.cs => MagicOnion_MagicOnionInitializer.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/{MagicOnion_Resolvers_MagicOnionResolver.cs => MagicOnion_Resolvers_MagicOnionResolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/{TempProject_MyHubClient.cs => TempProject_MyHubClient.g.cs} (100%) diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 084db6775..0b547f03b 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -23,7 +23,7 @@ public void Execute(GeneratorExecutionContext context) var outputs = compiler.GenerateAsync(context.Compilation, "MagicOnionClient.g.cs", disableAutoRegister: false, @namespace: @namespace, - userDefinedFormattersNamespace: "MessagePack.Formatter", + userDefinedFormattersNamespace: "MessagePack.Formatters", serializerType: SerializerType.MessagePack ).GetAwaiter().GetResult(); diff --git a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs b/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs index b9d261724..421d18827 100644 --- a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs +++ b/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs @@ -188,7 +188,7 @@ SerializerType serializerType static string GeneratePathFromNamespaceAndTypeName(string ns, string className) { - return $"{ns}_{className}".Replace(".", "_").Replace("global::", string.Empty) + ".cs"; + return $"{ns}_{className}".Replace(".", "_").Replace("global::", string.Empty) + ".g.cs"; } static string WithAutoGenerated(string s) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs new file mode 100644 index 000000000..d0ed4a7ee --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs @@ -0,0 +1,648 @@ +using MagicOnion.Client.SourceGenerator.Tests.Verifiers; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public class GenerateGenericsTest +{ + [Fact] + public async Task Parameters() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + using System.Collections.Generic; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult A(MyGenericObject a); + UnaryResult B(MyGenericObject a); + UnaryResult>> C(); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_Nested() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult A(MyGenericObject> a); + UnaryResult B(MyGenericObject>> a); + UnaryResult C(MyGenericObject>> a); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_Nested_Enum() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetEnumAsync(MyGenericObject> arg0); + } + + public enum MyEnum + { + A, B, C + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_Nested_Array() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetValuesAsync(MyGenericObject arg0); + } + + public class MyGenericObject + { + } + + public class MyNestedGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_ListFormatter_KnownType() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetStringValuesAsync(List arg0); + UnaryResult GetIntValuesAsync(List arg0); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_ListFormatter_UserType() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetValuesAsync(List arg0); + } + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_ArrayFormatter_KnownType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetStringValuesAsync(string[] arg0); + UnaryResult GetIntValuesAsync(int[] arg0); + UnaryResult GetInt32ValuesAsync(Int32[] arg0); + UnaryResult GetSingleValuesAsync(float[] arg0); + UnaryResult GetBooleanValuesAsync(bool[] arg0); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_ArrayFormatter_UserType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetValuesAsync(MyResponse[] arg0); + } + + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult> A(); + UnaryResult> B(); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_Nested() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult>> A(); + UnaryResult>>> B(); + UnaryResult>>> C(); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_MultipleTypeArgs() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult> A(); + UnaryResult> B(); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_Enum() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult> GetEnumAsync(); + } + + public enum MyEnum + { + A, B, C + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_Nested_Enum() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult>> GetEnumAsync(); + } + + public enum MyEnum + { + A, B, C + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_Nested_Array() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult> GetValuesAsync(); + } + + public class MyGenericObject + { + } + + public class MyNestedGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_ListFormatter_KnownType() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult> GetStringValuesAsync(); + UnaryResult> GetIntValuesAsync(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_ListFormatter_UserType() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult> GetValuesAsync(); + } + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_ArrayFormatter_KnownType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetStringValuesAsync(); + UnaryResult GetIntValuesAsync(); + UnaryResult GetInt32ValuesAsync(); + UnaryResult GetSingleValuesAsync(); + UnaryResult GetBooleanValuesAsync(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_ArrayFormatter_UserType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetValuesAsync(); + } + + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task KnownFormatters() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult> MethodList(List args); + UnaryResult> MethodIList(); + UnaryResult> MethodIROList(); + + UnaryResult> MethodDictionary(); + UnaryResult> MethodIDictionary(); + UnaryResult> MethodIRODictionary(); + + UnaryResult> MethodIEnumerable(); + UnaryResult> MethodICollection(); + UnaryResult> MethodIROCollection(); + + UnaryResult> MethodILookup(); + UnaryResult> MethodIGrouping(); + } + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateRawStreamingTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateRawStreamingTest.cs new file mode 100644 index 000000000..b3302a514 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateRawStreamingTest.cs @@ -0,0 +1,29 @@ +using MagicOnion.Client.SourceGenerator.Tests.Verifiers; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public class GenerateRawStreamingTest +{ + [Fact] + public async Task StreamingResult() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + using System.Threading.Tasks; + + namespace TempProject + { + public interface IMyService : IService + { + Task> ClientStreamingAsync(); + Task> ServerStreamingAsync(); + Task> DuplexStreamingAsync(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj index caac74e20..89da8b6fc 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj @@ -34,5 +34,8 @@ + + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20bb91d74 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,121 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(12) + { + {typeof(global::System.Collections.Generic.Dictionary), 0 }, + {typeof(global::System.Collections.Generic.ICollection), 1 }, + {typeof(global::System.Collections.Generic.IDictionary), 2 }, + {typeof(global::System.Collections.Generic.IEnumerable), 3 }, + {typeof(global::System.Collections.Generic.IList), 4 }, + {typeof(global::System.Collections.Generic.IReadOnlyCollection), 5 }, + {typeof(global::System.Collections.Generic.IReadOnlyDictionary), 6 }, + {typeof(global::System.Collections.Generic.IReadOnlyList), 7 }, + {typeof(global::System.Collections.Generic.List), 8 }, + {typeof(global::System.Collections.Generic.List), 9 }, + {typeof(global::System.Linq.IGrouping), 10 }, + {typeof(global::System.Linq.ILookup), 11 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.DictionaryFormatter(); + case 1: return new global::MessagePack.Formatters.InterfaceCollectionFormatter2(); + case 2: return new global::MessagePack.Formatters.InterfaceDictionaryFormatter(); + case 3: return new global::MessagePack.Formatters.InterfaceEnumerableFormatter(); + case 4: return new global::MessagePack.Formatters.InterfaceListFormatter2(); + case 5: return new global::MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter(); + case 6: return new global::MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter(); + case 7: return new global::MessagePack.Formatters.InterfaceReadOnlyListFormatter(); + case 8: return new global::MessagePack.Formatters.ListFormatter(); + case 9: return new global::MessagePack.Formatters.ListFormatter(); + case 10: return new global::MessagePack.Formatters.InterfaceGroupingFormatter(); + case 11: return new global::MessagePack.Formatters.InterfaceLookupFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..e4a60c342 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs @@ -0,0 +1,94 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.Collections.Generic.List> MethodList; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIList; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIROList; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodDictionary; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIDictionary; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIRODictionary; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIEnumerable; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodICollection; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIROCollection; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodILookup; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIGrouping; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.MethodList = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType, global::System.Collections.Generic.List>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodList", serializerProvider); + this.MethodIList = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIList", serializerProvider); + this.MethodIROList = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIROList", serializerProvider); + this.MethodDictionary = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodDictionary", serializerProvider); + this.MethodIDictionary = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIDictionary", serializerProvider); + this.MethodIRODictionary = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIRODictionary", serializerProvider); + this.MethodIEnumerable = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIEnumerable", serializerProvider); + this.MethodICollection = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodICollection", serializerProvider); + this.MethodIROCollection = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIROCollection", serializerProvider); + this.MethodILookup = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodILookup", serializerProvider); + this.MethodIGrouping = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIGrouping", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> MethodList(global::System.Collections.Generic.List args) + => this.core.MethodList.InvokeUnary(this, "IMyService/MethodList", args); + public global::MagicOnion.UnaryResult> MethodIList() + => this.core.MethodIList.InvokeUnary(this, "IMyService/MethodIList", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIROList() + => this.core.MethodIROList.InvokeUnary(this, "IMyService/MethodIROList", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodDictionary() + => this.core.MethodDictionary.InvokeUnary(this, "IMyService/MethodDictionary", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIDictionary() + => this.core.MethodIDictionary.InvokeUnary(this, "IMyService/MethodIDictionary", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIRODictionary() + => this.core.MethodIRODictionary.InvokeUnary(this, "IMyService/MethodIRODictionary", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIEnumerable() + => this.core.MethodIEnumerable.InvokeUnary(this, "IMyService/MethodIEnumerable", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodICollection() + => this.core.MethodICollection.InvokeUnary(this, "IMyService/MethodICollection", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIROCollection() + => this.core.MethodIROCollection.InvokeUnary(this, "IMyService/MethodIROCollection", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodILookup() + => this.core.MethodILookup.InvokeUnary(this, "IMyService/MethodILookup", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIGrouping() + => this.core.MethodIGrouping.InvokeUnary(this, "IMyService/MethodIGrouping", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..388515710 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,96 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + {typeof(global::System.Collections.Generic.IReadOnlyList), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyGenericObject), 2 }, + {typeof(global::TempProject.MyGenericObject), 3 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.InterfaceReadOnlyListFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..3df028e78 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs @@ -0,0 +1,62 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> B; + public global::MagicOnion.Client.Internal.RawMethodInvoker>> C; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A(global::TempProject.MyGenericObject a) + => this.core.A.InvokeUnary(this, "IMyService/A", a); + public global::MagicOnion.UnaryResult B(global::TempProject.MyGenericObject a) + => this.core.B.InvokeUnary(this, "IMyService/B", a); + public global::MagicOnion.UnaryResult>> C() + => this.core.C.InvokeUnary(this, "IMyService/C", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 62% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index f7091288a..cfb871632 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_Resolvers_MagicOnionResolver.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -45,11 +45,8 @@ internal static class MagicOnionResolverGetFormatterHelper static MagicOnionResolverGetFormatterHelper() { - lookup = new global::System.Collections.Generic.Dictionary(3) + lookup = new global::System.Collections.Generic.Dictionary(0) { - {typeof(global::ILookup), 0 }, - {typeof(global::IReadOnlyList), 1 }, - {typeof(global::MagicOnion.DynamicArgumentTuple, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>), 2 }, }; } internal static object GetFormatter(Type t) @@ -62,9 +59,6 @@ internal static object GetFormatter(Type t) switch (key) { - case 0: return new global::MessagePack.Formatter.ILookupFormatter(); - case 1: return new global::MessagePack.Formatter.IReadOnlyListFormatter(); - case 2: return new global::MagicOnion.DynamicArgumentTupleFormatter, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>(default(global::Int32), default(global::IReadOnlyList), default(global::FileMode), default(global::ILookup), default(global::ClientCertificateOption), default(global::ApartmentState), default(global::TaskCreationOptions)); default: return null; } } @@ -76,17 +70,15 @@ internal static class TypeHints [MagicOnion.Resolvers.Preserve] internal static void Register() { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>>(); _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); } } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..a25a7b56c --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -0,0 +1,70 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetStringValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetIntValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetInt32ValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetSingleValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetBooleanValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); + this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); + this.GetInt32ValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetInt32ValuesAsync", serializerProvider); + this.GetSingleValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetSingleValuesAsync", serializerProvider); + this.GetBooleanValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetBooleanValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetStringValuesAsync(global::System.String[] arg0) + => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetIntValuesAsync(global::System.Int32[] arg0) + => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetInt32ValuesAsync(global::System.Int32[] arg0) + => this.core.GetInt32ValuesAsync.InvokeUnary(this, "IMyService/GetInt32ValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetSingleValuesAsync(global::System.Single[] arg0) + => this.core.GetSingleValuesAsync.InvokeUnary(this, "IMyService/GetSingleValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetBooleanValuesAsync(global::System.Boolean[] arg0) + => this.core.GetBooleanValuesAsync.InvokeUnary(this, "IMyService/GetBooleanValuesAsync", arg0); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..afc535ddc --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyResponse[]), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MyNamespace_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs similarity index 55% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MyNamespace_MyServiceClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs index 1f65f72b2..b7aaa46e1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MyNamespace_MyServiceClient.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -11,7 +11,7 @@ #pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. #pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. -namespace MyNamespace +namespace TempProject { using global::System; using global::Grpc.Core; @@ -20,14 +20,14 @@ namespace MyNamespace using global::MessagePack; [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyNamespace.IMyService + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { class ClientCore { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>, global::MessagePack.Nil> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetValuesAsync; public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); } } @@ -46,8 +46,8 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - public global::MagicOnion.UnaryResult A(global::Int32 arg0, global::IReadOnlyList arg1, global::FileMode arg2, global::ILookup arg3, global::ClientCertificateOption arg4, global::ApartmentState arg5, global::TaskCreationOptions arg6) - => this.core.A.InvokeUnary(this, "IMyService/A", new global::MagicOnion.DynamicArgumentTuple, global::FileMode, global::ILookup, global::ClientCertificateOption, global::ApartmentState, global::TaskCreationOptions>(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); + public global::MagicOnion.UnaryResult GetValuesAsync(global::TempProject.MyResponse[] arg0) + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..187188606 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Collections.Generic.List), 0 }, + {typeof(global::System.Collections.Generic.List), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + case 1: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..57ef04b35 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -0,0 +1,58 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetStringValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetIntValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); + this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetStringValuesAsync(global::System.Collections.Generic.List arg0) + => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetIntValuesAsync(global::System.Collections.Generic.List arg0) + => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", arg0); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..a131e74f3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::System.Collections.Generic.List), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..572388ee5 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetValuesAsync(global::System.Collections.Generic.List arg0) + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs similarity index 96% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs index 8c8361ed2..2c81cbf4f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -65,9 +65,9 @@ static MagicOnionClientFactoryCache() { object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - if (typeof(T) == typeof(global::MyNamespace.IMyService)) + if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyNamespace.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20dcaa25a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,102 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyGenericObject>>), 2 }, + {typeof(global::TempProject.MyGenericObject>>), 3 }, + {typeof(global::TempProject.MyGenericObject>), 4 }, + {typeof(global::TempProject.MyGenericObject), 5 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..e36824126 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs @@ -0,0 +1,62 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker>, global::MessagePack.Nil> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker>>, global::MessagePack.Nil> B; + public global::MagicOnion.Client.Internal.RawMethodInvoker>>, global::MessagePack.Nil> C; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A(global::TempProject.MyGenericObject> a) + => this.core.A.InvokeUnary(this, "IMyService/A", a); + public global::MagicOnion.UnaryResult B(global::TempProject.MyGenericObject>> a) + => this.core.B.InvokeUnary(this, "IMyService/B", a); + public global::MagicOnion.UnaryResult C(global::TempProject.MyGenericObject>> a) + => this.core.C.InvokeUnary(this, "IMyService/C", a); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..b2be10399 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,89 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyNestedGenericObject[]), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..15233ae35 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetValuesAsync(global::TempProject.MyGenericObject arg0) + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20067d772 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyEnum), 2 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..6a1e7e374 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker>, global::MessagePack.Nil> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetEnumAsync(global::TempProject.MyGenericObject> arg0) + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", arg0); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..8a0ee8195 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..9d9133d18 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs @@ -0,0 +1,58 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker> B; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> B() + => this.core.B.InvokeUnary(this, "IMyService/B", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..cfb871632 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..d746391e3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -0,0 +1,70 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetStringValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetIntValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetInt32ValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetSingleValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetBooleanValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); + this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); + this.GetInt32ValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetInt32ValuesAsync", serializerProvider); + this.GetSingleValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetSingleValuesAsync", serializerProvider); + this.GetBooleanValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetBooleanValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetStringValuesAsync() + => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult GetIntValuesAsync() + => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult GetInt32ValuesAsync() + => this.core.GetInt32ValuesAsync.InvokeUnary(this, "IMyService/GetInt32ValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult GetSingleValuesAsync() + => this.core.GetSingleValuesAsync.InvokeUnary(this, "IMyService/GetSingleValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult GetBooleanValuesAsync() + => this.core.GetBooleanValuesAsync.InvokeUnary(this, "IMyService/GetBooleanValuesAsync", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..afc535ddc --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyResponse[]), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..7e2cc6e02 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetValuesAsync() + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..356a451bb --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyEnum), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..018db0046 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> GetEnumAsync() + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..187188606 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Collections.Generic.List), 0 }, + {typeof(global::System.Collections.Generic.List), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + case 1: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..fa330b4df --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -0,0 +1,58 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetStringValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetIntValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); + this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> GetStringValuesAsync() + => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> GetIntValuesAsync() + => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..a131e74f3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::System.Collections.Generic.List), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..f23b1855b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> GetValuesAsync() + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..f74a4a02b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..dbf2d0158 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs @@ -0,0 +1,58 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker> B; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> B() + => this.core.B.InvokeUnary(this, "IMyService/B", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20dcaa25a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,102 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyGenericObject>>), 2 }, + {typeof(global::TempProject.MyGenericObject>>), 3 }, + {typeof(global::TempProject.MyGenericObject>), 4 }, + {typeof(global::TempProject.MyGenericObject), 5 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..2c905e6fb --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs @@ -0,0 +1,62 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker>> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker>>> B; + public global::MagicOnion.Client.Internal.RawMethodInvoker>>> C; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult>> A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult>>> B() + => this.core.B.InvokeUnary(this, "IMyService/B", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult>>> C() + => this.core.C.InvokeUnary(this, "IMyService/C", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..b2be10399 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,89 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyNestedGenericObject[]), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..433ca0972 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> GetValuesAsync() + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20067d772 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyEnum), 2 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..8e054fe7e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker>> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult>> GetEnumAsync() + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..46bf03d4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs @@ -0,0 +1,62 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker ClientStreamingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker ServerStreamingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker DuplexStreamingAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.ClientStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.ClientStreaming, "IMyService", "ClientStreamingAsync", serializerProvider); + this.ServerStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.ServerStreaming, "IMyService", "ServerStreamingAsync", serializerProvider); + this.DuplexStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.DuplexStreaming, "IMyService", "DuplexStreamingAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::System.Threading.Tasks.Task> ClientStreamingAsync() + => this.core.ClientStreamingAsync.InvokeClientStreaming(this, "IMyService/ClientStreamingAsync"); + public global::System.Threading.Tasks.Task> ServerStreamingAsync() + => this.core.ServerStreamingAsync.InvokeServerStreaming(this, "IMyService/ServerStreamingAsync", global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> DuplexStreamingAsync() + => this.core.DuplexStreamingAsync.InvokeDuplexStreaming(this, "IMyService/DuplexStreamingAsync"); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..5e0445213 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Disable/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MyApplication1_GreeterServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MyApplication1_GreeterServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MyApplication1_GreeterServiceClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MyApplication1_GreeterServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index 4c0b8e52a..4599cac1b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -1,4 +1,4 @@ -#define WRITE_EXPECTED +//#define WRITE_EXPECTED // https://github.com/MessagePack-CSharp/MessagePack-CSharp/blob/develop/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier%601%2BTest.cs // https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#unit-testing-of-generators From d3164b85678b36600971f1da6a0e6144a494215d Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 5 Oct 2023 10:30:01 +0900 Subject: [PATCH 03/66] WIP --- .../GenerateEnumFormatterTest.cs | 134 +++ .../GenerateGenericsStreamingHubTest.cs | 1052 +++++++++++++++++ ...on_Formatters_MyClass_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 88 ++ .../TempProject_MyServiceClient.g.cs | 54 + ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 85 ++ .../TempProject_MyServiceClient.g.cs | 54 + ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 88 ++ .../TempProject_MyServiceClient.g.cs | 54 + ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 85 ++ .../TempProject_MyServiceClient.g.cs | 54 + ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 88 ++ .../TempProject_MyServiceClient.g.cs | 54 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../HubReceiver/TempProject_MyHubClient.g.cs | 82 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../TempProject_MyHubClient.g.cs | 100 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 ++ .../TempProject_MyHubClient.g.cs | 76 ++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 88 ++ .../TempProject_MyHubClient.g.cs | 76 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../TempProject_MyHubClient.g.cs | 82 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 ++ .../TempProject_MyHubClient.g.cs | 76 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../TempProject_MyHubClient.g.cs | 82 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 102 ++ .../TempProject_MyHubClient.g.cs | 88 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 ++ .../TempProject_MyHubClient.g.cs | 76 ++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 91 ++ .../TempProject_MyHubClient.g.cs | 76 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../Parameters/TempProject_MyHubClient.g.cs | 84 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../TempProject_MyHubClient.g.cs | 105 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 ++ .../TempProject_MyHubClient.g.cs | 77 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../TempProject_MyHubClient.g.cs | 84 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 ++ .../TempProject_MyHubClient.g.cs | 77 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../TempProject_MyHubClient.g.cs | 84 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 102 ++ .../TempProject_MyHubClient.g.cs | 91 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 ++ .../TempProject_MyHubClient.g.cs | 77 ++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 91 ++ .../TempProject_MyHubClient.g.cs | 77 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../Return/TempProject_MyHubClient.g.cs | 84 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../TempProject_MyHubClient.g.cs | 105 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 ++ .../TempProject_MyHubClient.g.cs | 77 ++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 88 ++ .../Return_Enum/TempProject_MyHubClient.g.cs | 77 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../TempProject_MyHubClient.g.cs | 84 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 ++ .../TempProject_MyHubClient.g.cs | 77 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 90 ++ .../TempProject_MyHubClient.g.cs | 84 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 102 ++ .../TempProject_MyHubClient.g.cs | 91 ++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 ++ .../TempProject_MyHubClient.g.cs | 77 ++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 33 + .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 91 ++ .../TempProject_MyHubClient.g.cs | 77 ++ 114 files changed, 10539 insertions(+) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/GenerateEnumFormatterTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateEnumFormatterTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateEnumFormatterTest.cs new file mode 100644 index 000000000..fa67f8b7d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateEnumFormatterTest.cs @@ -0,0 +1,134 @@ +using MagicOnion.Client.SourceGenerator.Tests.Verifiers; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public class GenerateEnumFormatterTest +{ + [Fact] + public async Task GenerateEnumFormatter_Return() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetEnumAsync(); + } + + public enum MyEnum + { + A, B, C + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task GenerateEnumFormatter_Return_Nullable() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetEnumAsync(); + } + + public enum MyEnum + { + A, B, C + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task GenerateEnumFormatter_Parameter() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetEnumAsync(MyEnum a); + } + + public enum MyEnum + { + A, B, C + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task GenerateEnumFormatter_Parameter_Nullable() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetEnumAsync(MyEnum? a); + } + + public enum MyEnum + { + A, B, C + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task GenerateEnumFormatter_Nested() + { + var source = """ + using System; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyService : IService + { + UnaryResult GetEnumAsync(MyClass.MyEnum? a); + } + + public class MyClass + { + public enum MyEnum + { + A, B, C + } + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs new file mode 100644 index 000000000..d5ffdcf34 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs @@ -0,0 +1,1052 @@ +using MagicOnion.Client.SourceGenerator.Tests.Verifiers; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public class GenerateGenericsStreamingHubTest +{ + [Fact] + public async Task Parameters() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task A(MyGenericObject a); + Task B(MyGenericObject a); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_MultipleTypeArgs() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task A(MyGenericObject a); + Task B(MyGenericObject a); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_Nested() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task A(MyGenericObject> a); + Task B(MyGenericObject>> a); + Task C(MyGenericObject>> a); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_Nested_Enum() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task GetEnumAsync(MyGenericObject> arg0); + } + + public enum MyEnum + { + A, B, C + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_Nested_Array() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task GetValuesAsync(MyGenericObject arg0); + } + + public class MyGenericObject + { + } + + public class MyNestedGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_ListFormatter_KnownType() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task GetStringValuesAsync(List arg0); + Task GetIntValuesAsync(List arg0); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_ListFormatter_UserType() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task GetValuesAsync(List arg0); + } + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_ArrayFormatter_KnownType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task GetStringValuesAsync(string[] arg0); + Task GetIntValuesAsync(int[] arg0); + Task GetInt32ValuesAsync(Int32[] arg0); + Task GetSingleValuesAsync(float[] arg0); + Task GetBooleanValuesAsync(bool[] arg0); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Parameters_ArrayFormatter_UserType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task GetValuesAsync(MyResponse[] arg0); + } + + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task> A(); + Task> B(); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_Nested() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task>> A(); + Task>>> B(); + Task>>> C(); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_MultipleTypeArgs() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task> A(); + Task> B(); + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_Enum() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task> GetEnumAsync(); + } + + public enum MyEnum + { + A, B, C + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_Nested_Enum() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task>> GetEnumAsync(); + } + + public enum MyEnum + { + A, B, C + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_Nested_Array() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task> GetValuesAsync(); + } + + public class MyGenericObject + { + } + + public class MyNestedGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_ListFormatter_KnownType() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task> GetStringValuesAsync(); + Task> GetIntValuesAsync(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_ListFormatter_UserType() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task> GetValuesAsync(); + } + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_ArrayFormatter_KnownType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task GetStringValuesAsync(); + Task GetIntValuesAsync(); + Task GetInt32ValuesAsync(); + Task GetSingleValuesAsync(); + Task GetBooleanValuesAsync(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Return_ArrayFormatter_UserType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver { } + public interface IMyHub : IStreamingHub + { + Task GetValuesAsync(); + } + + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void A(MyGenericObject a); + void B(MyGenericObject b); + } + public interface IMyHub : IStreamingHub + { + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_Nested() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void A(MyGenericObject> a); + void B(MyGenericObject>> b); + void C(MyGenericObject>> c); + } + public interface IMyHub : IStreamingHub + { + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_MultipleTypeArgs() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void A(MyGenericObject a); + void B(MyGenericObject b); + } + public interface IMyHub : IStreamingHub + { + } + + [MessagePackObject] + public class MyObject + { + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_Enum() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void A(MyGenericObject a); + } + public interface IMyHub : IStreamingHub + { + } + + public enum MyEnum + { + A, B, C + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_Nested_Enum() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void A(MyGenericObject> a); + } + public interface IMyHub : IStreamingHub + { + } + + public enum MyEnum + { + A, B, C + } + + [MessagePackObject] + public class MyGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_Nested_Array() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void A(MyGenericObject a); + } + public interface IMyHub : IStreamingHub + { + } + + public class MyGenericObject + { + } + + public class MyNestedGenericObject + { + } + } + + // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) + namespace MessagePack.Formatters.TempProject + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_ListFormatter_KnownType() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void A(List a); + void B(List b); + } + public interface IMyHub : IStreamingHub + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_ListFormatter_UserType() + { + var source = """ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void A(List a); + } + public interface IMyHub : IStreamingHub + { + } + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_ArrayFormatter_KnownType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void A(string[] a); + void B(int[] a); + void C(Int32[] a); + void D(float[] a); + void E(bool[] a); + } + public interface IMyHub : IStreamingHub + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task HubReceiver_ArrayFormatter_UserType() + { + var source = """ + using System; + using System.Threading.Tasks; + using MessagePack; + using MagicOnion; + + namespace TempProject + { + public interface IMyHubReceiver + { + void A(MyResponse[] a); + } + public interface IMyHub : IStreamingHub + { + } + + public class MyResponse + { + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs new file mode 100644 index 000000000..16766cdb6 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyClass_MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyClass.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyClass.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyClass.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..149cab4a5 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Nullable), 0 }, + {typeof(global::TempProject.MyClass.MyEnum), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.NullableFormatter(); + case 1: return new MagicOnion.Formatters.MyClass_MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..268d11007 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetEnumAsync(global::System.Nullable a) + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..edebc2067 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,85 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyEnum), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..011d77817 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetEnumAsync(global::TempProject.MyEnum a) + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..f3e6f648e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Nullable), 0 }, + {typeof(global::TempProject.MyEnum), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.NullableFormatter(); + case 1: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..37921a938 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetEnumAsync(global::System.Nullable a) + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..edebc2067 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,85 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyEnum), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..8bf4ff3f4 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetEnumAsync() + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..2c81cbf4f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..f3e6f648e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Nullable), 0 }, + {typeof(global::TempProject.MyEnum), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.NullableFormatter(); + case 1: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs new file mode 100644 index 000000000..2b3ce59a8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> GetEnumAsync() + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..8a0ee8195 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..937d09643 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Void A(global::TempProject.MyGenericObject a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; + case -955516027: // Void B(global::TempProject.MyGenericObject b) + { + var value = base.Deserialize>(data); + receiver.B(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..cfb871632 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..2c761ea0b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -0,0 +1,100 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Void A(global::System.String[] a) + { + var value = base.Deserialize(data); + receiver.A(value); + } + break; + case -955516027: // Void B(global::System.Int32[] a) + { + var value = base.Deserialize(data); + receiver.B(value); + } + break; + case -972293646: // Void C(global::System.Int32[] a) + { + var value = base.Deserialize(data); + receiver.C(value); + } + break; + case -1056181741: // Void D(global::System.Single[] a) + { + var value = base.Deserialize(data); + receiver.D(value); + } + break; + case -1072959360: // Void E(global::System.Boolean[] a) + { + var value = base.Deserialize(data); + receiver.E(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..afc535ddc --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyResponse[]), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..79569447a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Void A(global::TempProject.MyResponse[] a) + { + var value = base.Deserialize(data); + receiver.A(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..356a451bb --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyEnum), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..f135340b0 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Void A(global::TempProject.MyGenericObject a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..187188606 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Collections.Generic.List), 0 }, + {typeof(global::System.Collections.Generic.List), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + case 1: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..76ab6935f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Void A(global::System.Collections.Generic.List a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; + case -955516027: // Void B(global::System.Collections.Generic.List b) + { + var value = base.Deserialize>(data); + receiver.B(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..a131e74f3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::System.Collections.Generic.List), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..ada5c5ae8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Void A(global::System.Collections.Generic.List a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..f74a4a02b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..95d405826 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Void A(global::TempProject.MyGenericObject a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; + case -955516027: // Void B(global::TempProject.MyGenericObject b) + { + var value = base.Deserialize>(data); + receiver.B(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20dcaa25a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,102 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyGenericObject>>), 2 }, + {typeof(global::TempProject.MyGenericObject>>), 3 }, + {typeof(global::TempProject.MyGenericObject>), 4 }, + {typeof(global::TempProject.MyGenericObject), 5 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..7ee80c869 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Void A(global::TempProject.MyGenericObject> a) + { + var value = base.Deserialize>>(data); + receiver.A(value); + } + break; + case -955516027: // Void B(global::TempProject.MyGenericObject>> b) + { + var value = base.Deserialize>>>(data); + receiver.B(value); + } + break; + case -972293646: // Void C(global::TempProject.MyGenericObject>> c) + { + var value = base.Deserialize>>>(data); + receiver.C(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..b2be10399 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,89 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyNestedGenericObject[]), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..b24daed4e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Void A(global::TempProject.MyGenericObject a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20067d772 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyEnum), 2 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..4686c9809 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Void A(global::TempProject.MyGenericObject> a) + { + var value = base.Deserialize>>(data); + receiver.A(value); + } + break; + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..8a0ee8195 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..61a0ba2f8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs @@ -0,0 +1,84 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-955516027, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-955516027, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyGenericObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -955516027: // Task B(global::TempProject.MyGenericObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..cfb871632 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..98017f888 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -0,0 +1,105 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.String[] arg0) + => base.WriteMessageWithResponseAsync(1774317884, arg0); + public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Int32[] arg0) + => base.WriteMessageWithResponseAsync(-400881550, arg0); + public global::System.Threading.Tasks.Task GetInt32ValuesAsync(global::System.Int32[] arg0) + => base.WriteMessageWithResponseAsync(309063297, arg0); + public global::System.Threading.Tasks.Task GetSingleValuesAsync(global::System.Single[] arg0) + => base.WriteMessageWithResponseAsync(702446639, arg0); + public global::System.Threading.Tasks.Task GetBooleanValuesAsync(global::System.Boolean[] arg0) + => base.WriteMessageWithResponseAsync(2082077357, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.String[] arg0) + => parent.WriteMessageFireAndForgetAsync(1774317884, arg0); + public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Int32[] arg0) + => parent.WriteMessageFireAndForgetAsync(-400881550, arg0); + public global::System.Threading.Tasks.Task GetInt32ValuesAsync(global::System.Int32[] arg0) + => parent.WriteMessageFireAndForgetAsync(309063297, arg0); + public global::System.Threading.Tasks.Task GetSingleValuesAsync(global::System.Single[] arg0) + => parent.WriteMessageFireAndForgetAsync(702446639, arg0); + public global::System.Threading.Tasks.Task GetBooleanValuesAsync(global::System.Boolean[] arg0) + => parent.WriteMessageFireAndForgetAsync(2082077357, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case 1774317884: // Task GetStringValuesAsync(global::System.String[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -400881550: // Task GetIntValuesAsync(global::System.Int32[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + case 309063297: // Task GetInt32ValuesAsync(global::System.Int32[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + case 702446639: // Task GetSingleValuesAsync(global::System.Single[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + case 2082077357: // Task GetBooleanValuesAsync(global::System.Boolean[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..afc535ddc --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyResponse[]), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..3a7306535 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyResponse[] arg0) + => base.WriteMessageWithResponseAsync(-209315513, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyResponse[] arg0) + => parent.WriteMessageFireAndForgetAsync(-209315513, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task GetValuesAsync(global::TempProject.MyResponse[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..187188606 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Collections.Generic.List), 0 }, + {typeof(global::System.Collections.Generic.List), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + case 1: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..6da9a56c2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -0,0 +1,84 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.Collections.Generic.List arg0) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(1774317884, arg0); + public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Collections.Generic.List arg0) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-400881550, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.Collections.Generic.List arg0) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(1774317884, arg0); + public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Collections.Generic.List arg0) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-400881550, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case 1774317884: // Task GetStringValuesAsync(global::System.Collections.Generic.List arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -400881550: // Task GetIntValuesAsync(global::System.Collections.Generic.List arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..a131e74f3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::System.Collections.Generic.List), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..4593761ef --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetValuesAsync(global::System.Collections.Generic.List arg0) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-209315513, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetValuesAsync(global::System.Collections.Generic.List arg0) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-209315513, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task GetValuesAsync(global::System.Collections.Generic.List arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..f74a4a02b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..d3e46f7f2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs @@ -0,0 +1,84 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-955516027, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-955516027, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyGenericObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -955516027: // Task B(global::TempProject.MyGenericObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20dcaa25a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,102 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyGenericObject>>), 2 }, + {typeof(global::TempProject.MyGenericObject>>), 3 }, + {typeof(global::TempProject.MyGenericObject>), 4 }, + {typeof(global::TempProject.MyGenericObject), 5 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..cd11c78ff --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject> a) + => base.WriteMessageWithResponseAsync>, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject>> a) + => base.WriteMessageWithResponseAsync>>, global::MessagePack.Nil>(-955516027, a); + public global::System.Threading.Tasks.Task C(global::TempProject.MyGenericObject>> a) + => base.WriteMessageWithResponseAsync>>, global::MessagePack.Nil>(-972293646, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject> a) + => parent.WriteMessageFireAndForgetAsync>, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject>> a) + => parent.WriteMessageFireAndForgetAsync>>, global::MessagePack.Nil>(-955516027, a); + public global::System.Threading.Tasks.Task C(global::TempProject.MyGenericObject>> a) + => parent.WriteMessageFireAndForgetAsync>>, global::MessagePack.Nil>(-972293646, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyGenericObject> a) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -955516027: // Task B(global::TempProject.MyGenericObject>> a) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -972293646: // Task C(global::TempProject.MyGenericObject>> a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..b2be10399 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,89 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyNestedGenericObject[]), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..cc77231b9 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyGenericObject arg0) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-209315513, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyGenericObject arg0) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-209315513, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task GetValuesAsync(global::TempProject.MyGenericObject arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20067d772 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyEnum), 2 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..28c32f652 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetEnumAsync(global::TempProject.MyGenericObject> arg0) + => base.WriteMessageWithResponseAsync>, global::MessagePack.Nil>(-1221306238, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetEnumAsync(global::TempProject.MyGenericObject> arg0) + => parent.WriteMessageFireAndForgetAsync>, global::MessagePack.Nil>(-1221306238, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1221306238: // Task GetEnumAsync(global::TempProject.MyGenericObject> arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..8a0ee8195 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..621a51692 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs @@ -0,0 +1,84 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> A() + => base.WriteMessageWithResponseAsync>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> B() + => base.WriteMessageWithResponseAsync>(-955516027, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> A() + => parent.WriteMessageFireAndForgetAsync>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> B() + => parent.WriteMessageFireAndForgetAsync>(-955516027, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task> A() + base.SetResultForResponse>(taskCompletionSource, data); + break; + case -955516027: // Task> B() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..cfb871632 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..34b3ccd62 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -0,0 +1,105 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetStringValuesAsync() + => base.WriteMessageWithResponseAsync(1774317884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetIntValuesAsync() + => base.WriteMessageWithResponseAsync(-400881550, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetInt32ValuesAsync() + => base.WriteMessageWithResponseAsync(309063297, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetSingleValuesAsync() + => base.WriteMessageWithResponseAsync(702446639, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetBooleanValuesAsync() + => base.WriteMessageWithResponseAsync(2082077357, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetStringValuesAsync() + => parent.WriteMessageFireAndForgetAsync(1774317884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetIntValuesAsync() + => parent.WriteMessageFireAndForgetAsync(-400881550, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetInt32ValuesAsync() + => parent.WriteMessageFireAndForgetAsync(309063297, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetSingleValuesAsync() + => parent.WriteMessageFireAndForgetAsync(702446639, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetBooleanValuesAsync() + => parent.WriteMessageFireAndForgetAsync(2082077357, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case 1774317884: // Task GetStringValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + case -400881550: // Task GetIntValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + case 309063297: // Task GetInt32ValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + case 702446639: // Task GetSingleValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + case 2082077357: // Task GetBooleanValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..afc535ddc --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyResponse[]), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..f1fd5a574 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetValuesAsync() + => base.WriteMessageWithResponseAsync(-209315513, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetValuesAsync() + => parent.WriteMessageFireAndForgetAsync(-209315513, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task GetValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..356a451bb --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,88 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyEnum), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..060078464 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> GetEnumAsync() + => base.WriteMessageWithResponseAsync>(-1221306238, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> GetEnumAsync() + => parent.WriteMessageFireAndForgetAsync>(-1221306238, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1221306238: // Task> GetEnumAsync() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..187188606 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Collections.Generic.List), 0 }, + {typeof(global::System.Collections.Generic.List), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + case 1: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..503fa857f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -0,0 +1,84 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> GetStringValuesAsync() + => base.WriteMessageWithResponseAsync>(1774317884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> GetIntValuesAsync() + => base.WriteMessageWithResponseAsync>(-400881550, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> GetStringValuesAsync() + => parent.WriteMessageFireAndForgetAsync>(1774317884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> GetIntValuesAsync() + => parent.WriteMessageFireAndForgetAsync>(-400881550, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case 1774317884: // Task> GetStringValuesAsync() + base.SetResultForResponse>(taskCompletionSource, data); + break; + case -400881550: // Task> GetIntValuesAsync() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..a131e74f3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::System.Collections.Generic.List), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..555d8a273 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> GetValuesAsync() + => base.WriteMessageWithResponseAsync>(-209315513, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> GetValuesAsync() + => parent.WriteMessageFireAndForgetAsync>(-209315513, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task> GetValuesAsync() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..f74a4a02b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,90 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..20f8a6169 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs @@ -0,0 +1,84 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> A() + => base.WriteMessageWithResponseAsync>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> B() + => base.WriteMessageWithResponseAsync>(-955516027, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> A() + => parent.WriteMessageFireAndForgetAsync>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> B() + => parent.WriteMessageFireAndForgetAsync>(-955516027, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task> A() + base.SetResultForResponse>(taskCompletionSource, data); + break; + case -955516027: // Task> B() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20dcaa25a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,102 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyGenericObject>>), 2 }, + {typeof(global::TempProject.MyGenericObject>>), 3 }, + {typeof(global::TempProject.MyGenericObject>), 4 }, + {typeof(global::TempProject.MyGenericObject), 5 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..7c0bc927c --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task>> A() + => base.WriteMessageWithResponseAsync>>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task>>> B() + => base.WriteMessageWithResponseAsync>>>(-955516027, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task>>> C() + => base.WriteMessageWithResponseAsync>>>(-972293646, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task>> A() + => parent.WriteMessageFireAndForgetAsync>>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task>>> B() + => parent.WriteMessageFireAndForgetAsync>>>(-955516027, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task>>> C() + => parent.WriteMessageFireAndForgetAsync>>>(-972293646, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task>> A() + base.SetResultForResponse>>(taskCompletionSource, data); + break; + case -955516027: // Task>>> B() + base.SetResultForResponse>>>(taskCompletionSource, data); + break; + case -972293646: // Task>>> C() + base.SetResultForResponse>>>(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..b2be10399 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,89 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyNestedGenericObject[]), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..12306bf64 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> GetValuesAsync() + => base.WriteMessageWithResponseAsync>(-209315513, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> GetValuesAsync() + => parent.WriteMessageFireAndForgetAsync>(-209315513, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task> GetValuesAsync() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..fc9fa7d0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +namespace MagicOnion.Formatters +{ + using System; + using MessagePack; + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d106ad797 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..20067d772 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,91 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::TempProject.MyGenericObject), 0 }, + {typeof(global::TempProject.MyGenericObject>), 1 }, + {typeof(global::TempProject.MyEnum), 2 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new MagicOnion.Formatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>>(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs new file mode 100644 index 000000000..7048bbfc2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs @@ -0,0 +1,77 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace TempProject +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task>> GetEnumAsync() + => base.WriteMessageWithResponseAsync>>(-1221306238, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly MyHubClient parent; + + public FireAndForgetClient(MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task>> GetEnumAsync() + => parent.WriteMessageFireAndForgetAsync>>(-1221306238, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1221306238: // Task>> GetEnumAsync() + base.SetResultForResponse>>(taskCompletionSource, data); + break; + } + } + + } +} + + From fd563237761742264fa7b9304a94ede73d0e5c52 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 5 Oct 2023 14:42:43 +0900 Subject: [PATCH 04/66] WIP --- MagicOnion.sln | 7 -- .../MagicOnion.Client.SourceGenerator.csproj | 4 + .../MagicOnionClientSourceGenerator.cs | 13 +-- .../GeneratorOptions.cs | 69 +++++++++++++ .../MagicOnion.GeneratorCore.csproj | 5 + .../MagicOnionCompiler.cs | 77 +++------------ .../GeneratorOptionsTest.cs | 87 +++++++++++++++++ ...cOnion.Client.SourceGenerator.Tests.csproj | 3 - .../MagicOnion_MagicOnionInitializer.g.cs | 92 ++++++++++++++++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 ++++++++++++++++ .../MyApplication1_GreeterServiceClient.g.cs | 54 +++++++++++ .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++++++++++++++++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 +++++++++++++++++ .../MyApplication1_GreeterServiceClient.g.cs | 54 +++++++++++ .../MyApplication1_GreeterServiceClient.g.cs | 54 +++++++++++ .../__Generated___MagicOnionInitializer.g.cs | 97 +++++++++++++++++++ ...erated___Resolvers_MagicOnionResolver.g.cs | 86 ++++++++++++++++ .../MagicOnionSourceGeneratorVerifier.cs | 11 ++- 18 files changed, 897 insertions(+), 88 deletions(-) create mode 100644 src/MagicOnion.GeneratorCore/GeneratorOptions.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs diff --git a/MagicOnion.sln b/MagicOnion.sln index 32166e40b..4226f5325 100644 --- a/MagicOnion.sln +++ b/MagicOnion.sln @@ -26,8 +26,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{15598FE3-2 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Abstractions", "src\MagicOnion.Abstractions\MagicOnion.Abstractions.csproj", "{2AD48C05-ED44-4E4F-B86B-A746E7F968A9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Generator", "src\MagicOnion.Generator\MagicOnion.Generator.csproj", "{963FD601-3CE6-42DE-9FAC-C70D5494FA9B}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.GeneratorCore", "src\MagicOnion.GeneratorCore\MagicOnion.GeneratorCore.csproj", "{EE768243-100A-4075-8823-C49EA086680A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{42EBB7E4-52D7-4E57-80AD-79FDD4900E13}" @@ -125,10 +123,6 @@ Global {2AD48C05-ED44-4E4F-B86B-A746E7F968A9}.Debug|Any CPU.Build.0 = Debug|Any CPU {2AD48C05-ED44-4E4F-B86B-A746E7F968A9}.Release|Any CPU.ActiveCfg = Release|Any CPU {2AD48C05-ED44-4E4F-B86B-A746E7F968A9}.Release|Any CPU.Build.0 = Release|Any CPU - {963FD601-3CE6-42DE-9FAC-C70D5494FA9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {963FD601-3CE6-42DE-9FAC-C70D5494FA9B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {963FD601-3CE6-42DE-9FAC-C70D5494FA9B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {963FD601-3CE6-42DE-9FAC-C70D5494FA9B}.Release|Any CPU.Build.0 = Release|Any CPU {EE768243-100A-4075-8823-C49EA086680A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EE768243-100A-4075-8823-C49EA086680A}.Debug|Any CPU.Build.0 = Debug|Any CPU {EE768243-100A-4075-8823-C49EA086680A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -249,7 +243,6 @@ Global {C79CE0BF-ED4C-47BE-822E-E82CF83FC68A} = {1987061F-8970-4018-8D58-6932961C9EB4} {7B7CFF27-CB38-4661-9CFC-473B4E38F0DE} = {FEE2B9AB-A1D0-41BA-A172-FC95935542DF} {2AD48C05-ED44-4E4F-B86B-A746E7F968A9} = {1987061F-8970-4018-8D58-6932961C9EB4} - {963FD601-3CE6-42DE-9FAC-C70D5494FA9B} = {1987061F-8970-4018-8D58-6932961C9EB4} {EE768243-100A-4075-8823-C49EA086680A} = {1987061F-8970-4018-8D58-6932961C9EB4} {5CDEE44D-8AC2-4E7C-90CC-669E336F2D15} = {FEE2B9AB-A1D0-41BA-A172-FC95935542DF} {FEE2B9AB-A1D0-41BA-A172-FC95935542DF} = {5A3F5158-7B17-4586-9885-9E60C1393185} diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index e4c1864e2..c6c976337 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -16,6 +16,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 0b547f03b..026a0e1fb 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -1,16 +1,12 @@ using MagicOnion.Generator; using MagicOnion.Generator.Internal; using Microsoft.CodeAnalysis; -using System.Linq; -using Microsoft.CodeAnalysis.CSharp.Syntax; namespace MagicOnion.Client.SourceGenerator; [Generator(LanguageNames.CSharp)] public class MagicOnionClientSourceGenerator : ISourceGenerator { - const string OptionsAttributeName = "MagicOnionClientSourceGeneratorOptions"; - public void Initialize(GeneratorInitializationContext context) { context.RegisterForSyntaxNotifications(() => new SyntaxContextReceiver()); @@ -18,14 +14,9 @@ public void Initialize(GeneratorInitializationContext context) public void Execute(GeneratorExecutionContext context) { - var @namespace = "MagicOnion"; var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance, context.CancellationToken); - var outputs = compiler.GenerateAsync(context.Compilation, "MagicOnionClient.g.cs", - disableAutoRegister: false, - @namespace: @namespace, - userDefinedFormattersNamespace: "MessagePack.Formatters", - serializerType: SerializerType.MessagePack - ).GetAwaiter().GetResult(); + var options = GeneratorOptions.Default; + var outputs = compiler.GenerateAsync(context.Compilation, options).GetAwaiter().GetResult(); var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxContextReceiver!; diff --git a/src/MagicOnion.GeneratorCore/GeneratorOptions.cs b/src/MagicOnion.GeneratorCore/GeneratorOptions.cs new file mode 100644 index 000000000..d0f3669e8 --- /dev/null +++ b/src/MagicOnion.GeneratorCore/GeneratorOptions.cs @@ -0,0 +1,69 @@ +using System.Collections.Immutable; +using System.Text.Json; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace MagicOnion.Generator; + +/* +[Option("u", "Do not use UnityEngine's RuntimeInitializeOnLoadMethodAttribute on MagicOnionInitializer. (Same as --disable-auto-register)")]bool noUseUnityAttr = false, +[Option("d", "Do not automatically call MagicOnionInitializer during start-up. (Automatic registration requires .NET 5+ or Unity)")]bool disableAutoRegister = false, +[Option("n", "The namespace of clients to generate.")]string @namespace = "MagicOnion", +[Option("m", "The namespace of pre-generated MessagePackFormatters.")]string messagepackFormatterNamespace = "MessagePack.Formatters", +[Option("s", "The serializer used for message serialization")] SerializerType serializer = SerializerType.MessagePack +*/ + +public record GeneratorOptions +{ + public const string JsonFileName = "MagicOnionClientGeneratorOptions.json"; + + public static GeneratorOptions Default { get; } = new GeneratorOptions(); + + /// + /// Gets or sets whether to disable automatically calling MagicOnionInitializer during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegister { get; init; } + + /// + /// Gets or sets the namespace of clients to generate. The default value is MagicOnion. + /// + public string Namespace { get; init; } = "MagicOnion"; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// + public SerializerType Serializer { get; init; } = SerializerType.MessagePack; + + public enum SerializerType + { + MessagePack, + MemoryPack + } + + public static GeneratorOptions Create(ImmutableArray additionalTexts, CancellationToken cancellationToken) + { + var options = Default; + + var optionsJsonFile = additionalTexts.FirstOrDefault(x => string.Equals(Path.GetFileName(x.Path), JsonFileName, StringComparison.InvariantCultureIgnoreCase)); + if (optionsJsonFile != null) + { + var content = optionsJsonFile.GetText(cancellationToken)?.ToString(); + if (content != null) + { + options = JsonSerializer.Deserialize(content, new JsonSerializerOptions() + { + AllowTrailingCommas = true, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + ReadCommentHandling = JsonCommentHandling.Skip, + }) ?? Default; + } + } + + return options; + } +} diff --git a/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj b/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj index b40ac0f9a..f39d95b5f 100644 --- a/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj +++ b/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj @@ -13,6 +13,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs b/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs index 421d18827..37a4c3746 100644 --- a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs +++ b/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs @@ -6,20 +6,12 @@ using System.Runtime.InteropServices; using MagicOnion.Generator.CodeAnalysis; using MagicOnion.Generator.CodeGen; -using MagicOnion.Generator.Utils; using MagicOnion.Generator.CodeGen.Extensions; using MagicOnion.Generator.Internal; -using System.Collections.Generic; using Microsoft.CodeAnalysis; namespace MagicOnion.Generator; -public enum SerializerType -{ - MessagePack, - MemoryPack, -} - public class MagicOnionCompiler { static readonly Encoding NoBomUtf8 = new UTF8Encoding(false); @@ -32,65 +24,22 @@ public MagicOnionCompiler(IMagicOnionGeneratorLogger logger, CancellationToken c this.logger = logger; this.cancellationToken = cancellationToken; } - - public async Task GenerateFileAsync( - string input, - string output, - bool disableAutoRegister, - string @namespace, - string conditionalSymbol, - string userDefinedFormattersNamespace, - SerializerType serializerType) - { - var conditionalSymbols = conditionalSymbol?.Split(',') ?? Array.Empty(); - - // Generator Start... - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:Input: {input}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:ConditionalSymbol: {conditionalSymbol}"); - - var sw = Stopwatch.StartNew(); - logger.Information("Project Compilation Start:" + input); - var compilation = await PseudoCompilation.CreateFromProjectAsync(new[] { input }, conditionalSymbols, logger, cancellationToken); - logger.Information("Project Compilation Complete:" + sw.Elapsed.ToString()); - - var outputs = await GenerateAsync(compilation, Path.GetFileName(output), disableAutoRegister, @namespace, userDefinedFormattersNamespace, serializerType); - - sw.Restart(); - logger.Information("Writing generated codes"); - if (Path.GetExtension(output) == ".cs") - { - Output(output, outputs[0].Source); - } - else - { - foreach (var o in outputs) - { - Output(o.Path, o.Source); - } - } - logger.Information("Writing generated codes Complete:" + sw.Elapsed.ToString()); - } - public async Task> GenerateAsync( Compilation compilation, - string generatedFileNameBase, - bool disableAutoRegister, - string @namespace, - string userDefinedFormattersNamespace, - SerializerType serializerType + GeneratorOptions options ) { var outputs = new List<(string Path, string Source)>(); // Prepare args - var namespaceDot = string.IsNullOrWhiteSpace(@namespace) ? string.Empty : @namespace + "."; + var namespaceDot = string.IsNullOrWhiteSpace(options.Namespace) ? string.Empty : options.Namespace + "."; // Generator Start... - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:DisableAutoRegister: {disableAutoRegister}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:Namespace: {@namespace}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:UserDefinedFormattersNamespace: {userDefinedFormattersNamespace}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:SerializerType: {serializerType}"); + logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:DisableAutoRegister: {options.DisableAutoRegister}"); + logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:Namespace: {options.Namespace}"); + logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:UserDefinedFormattersNamespace: {options.MessagePackFormatterNamespace}"); + logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:SerializerType: {options.Serializer}"); logger.Trace($"[{nameof(MagicOnionCompiler)}] Assembly version: {typeof(MagicOnionCompiler).Assembly.GetCustomAttribute().InformationalVersion}"); logger.Trace($"[{nameof(MagicOnionCompiler)}] RuntimeInformation.OSDescription: {RuntimeInformation.OSDescription}"); logger.Trace($"[{nameof(MagicOnionCompiler)}] RuntimeInformation.ProcessArchitecture: {RuntimeInformation.ProcessArchitecture}"); @@ -98,17 +47,17 @@ SerializerType serializerType // Configure serialization (ISerializationFormatterNameMapper Mapper, string Namespace, string InitializerName, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) - serialization = serializerType switch + serialization = options.Serializer switch { - SerializerType.MemoryPack => ( + GeneratorOptions.SerializerType.MemoryPack => ( Mapper: new MemoryPackFormatterNameMapper(), - Namespace: @namespace, + Namespace: options.Namespace, InitializerName: "MagicOnionMemoryPackFormatterProvider", Generator: new MemoryPackFormatterRegistrationGenerator(), EnumFormatterGenerator: _ => string.Empty ), - SerializerType.MessagePack => ( - Mapper: new MessagePackFormatterNameMapper(userDefinedFormattersNamespace), + GeneratorOptions.SerializerType.MessagePack => ( + Mapper: new MessagePackFormatterNameMapper(options.MessagePackFormatterNamespace), Namespace: namespaceDot + "Resolvers", InitializerName: "MagicOnionResolver", Generator: new MessagePackFormatterResolverGenerator(), @@ -144,10 +93,10 @@ SerializerType serializerType var registerTemplate = new RegisterTemplate { - Namespace = @namespace, + Namespace = options.Namespace, Services = serviceCollection.Services, Hubs = serviceCollection.Hubs, - DisableAutoRegisterOnInitialize = disableAutoRegister, + DisableAutoRegisterOnInitialize = options.DisableAutoRegister, }; var formatterCodeGenContext = new SerializationFormatterCodeGenContext(serialization.Namespace, namespaceDot + "Formatters", serialization.InitializerName, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs new file mode 100644 index 000000000..02353f9c0 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs @@ -0,0 +1,87 @@ +using MagicOnion.Client.SourceGenerator.Tests.Verifiers; +using MagicOnion.Generator; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public class GeneratorOptionsTest +{ + [Fact] + public async Task DisableAutoRegister() + { + var source = """ + using MagicOnion; + + namespace MyApplication1; + + public interface IGreeterService : IService + { + UnaryResult HelloAsync(string name, int age); + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source, options: GeneratorOptions.Default with { DisableAutoRegister = true }); + } + + [Fact] + public async Task Namespace() + { + var source = """ + using MagicOnion; + + namespace MyApplication1; + + public interface IGreeterService : IService + { + UnaryResult HelloAsync(string name, int age); + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source, options: GeneratorOptions.Default with { Namespace = "__Generated__" }); + } + + [Fact] + public async Task MessagePackFormatterNamespace() + { + var source = """ + using MagicOnion; + + namespace MyApplication1 + { + public interface IGreeterService : IService + { + UnaryResult> HelloAsync(string name, int age); + } + + public class MyGenericObject {} + } + + namespace __UserDefined__.MessagePack.Formatters.MyApplication1 + { + public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + { + public void Serialize(ref MessagePackWriter writer, global::MyApplication1.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::MyApplication1.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + } + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source, options: GeneratorOptions.Default with { MessagePackFormatterNamespace = "__UserDefined__.MessagePack.Formatters." }); + } + + [Fact] + public async Task Serializer_MemoryPack() + { + var source = """ + using MagicOnion; + + namespace MyApplication1; + + public interface IGreeterService : IService + { + UnaryResult HelloAsync(string name, int age); + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source, options: GeneratorOptions.Default with { Serializer = GeneratorOptions.SerializerType.MemoryPack }); + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj index 89da8b6fc..caac74e20 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj @@ -34,8 +34,5 @@ - - - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..0874843fe --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,92 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..9a2a12c41 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs new file mode 100644 index 000000000..0e3ddaf1f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MyApplication1 +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d013f540a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..32bea4244 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,89 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, + {typeof(global::MyApplication1.MyGenericObject), 1 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + case 1: return new global::__UserDefined__.MessagePack.Formatters.MyApplication1.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs new file mode 100644 index 000000000..b5019d65d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MyApplication1 +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MyApplication1.MyGenericObject> HelloAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::MyApplication1.MyGenericObject>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult> HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs new file mode 100644 index 000000000..0e3ddaf1f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MyApplication1 +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d45926cad --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace __Generated__ +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..5ac8ea1d0 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace __Generated__.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index 4599cac1b..e36d0a8ea 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -3,11 +3,14 @@ // https://github.com/MessagePack-CSharp/MessagePack-CSharp/blob/develop/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier%601%2BTest.cs // https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#unit-testing-of-generators +using System.Collections.Immutable; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Text; +using MagicOnion.Generator; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; using Microsoft.CodeAnalysis.Text; @@ -17,15 +20,16 @@ namespace MagicOnion.Client.SourceGenerator.Tests.Verifiers; internal class MagicOnionSourceGeneratorVerifier { - public static async Task RunAsync(string testSourceCode, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) + public static async Task RunAsync(string testSourceCode, GeneratorOptions? options = null, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) { if (string.IsNullOrEmpty(testSourceCode)) throw new ArgumentNullException(nameof(testSourceCode)); if (string.IsNullOrEmpty(testFile)) throw new ArgumentNullException(nameof(testFile)); if (string.IsNullOrEmpty(testMethod)) throw new ArgumentNullException(nameof(testMethod)); - await RunAsync(new[] { ("Source.cs", testSourceCode) }, testFile, testMethod); + await RunAsync(new[] { ("Source.cs", testSourceCode) }, options, testFile, testMethod); } - public static async Task RunAsync(IEnumerable<(string Path, string Content)> testSourceCodes, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) + + public static async Task RunAsync(IEnumerable<(string Path, string Content)> testSourceCodes, GeneratorOptions? options = null, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) { if (testSourceCodes is null) throw new ArgumentNullException(nameof(testSourceCodes)); if (string.IsNullOrEmpty(testFile)) throw new ArgumentNullException(nameof(testFile)); @@ -50,6 +54,7 @@ public Test(string testFile, string testMethod) { this.testFile = testFile; this.testMethod = testMethod; + this.ReferenceAssemblies = ReferenceAssemblies.Net.Net60; this.AddAdditionalReferences(); From 219f7e965d9c0ed07ca6d93a51be12e9ecfee57a Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 5 Oct 2023 15:05:44 +0900 Subject: [PATCH 05/66] WIP --- MagicOnion.sln | 7 ++ .../MagicOnionClientSourceGenerator.cs | 2 +- .../GeneratorOptions.cs | 17 ++- .../GenerateGenericsStreamingHubTest.cs | 104 +++++++++--------- .../GenerateGenericsTest.cs | 60 +++++----- .../GeneratorOptionsTest.cs | 26 ++++- .../MagicOnion_MagicOnionInitializer.g.cs | 97 ++++++++++++++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 86 +++++++++++++++ .../MyApplication1_GreeterServiceClient.g.cs | 54 +++++++++ ...erated___Resolvers_MagicOnionResolver.g.cs | 4 +- .../MagicOnionSourceGeneratorVerifier.cs | 8 +- 11 files changed, 369 insertions(+), 96 deletions(-) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs diff --git a/MagicOnion.sln b/MagicOnion.sln index 4226f5325..0fa03ec05 100644 --- a/MagicOnion.sln +++ b/MagicOnion.sln @@ -105,6 +105,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicOnion.Client.SourceGen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGenerator.Tests", "tests\MagicOnion.Client.SourceGenerator.Tests\MagicOnion.Client.SourceGenerator.Tests.csproj", "{632C8D1B-3293-4D02-9ED1-0CB191619334}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Generator", "src\MagicOnion.Generator\MagicOnion.Generator.csproj", "{1BE960DA-4F54-4128-AEAE-993960DB9455}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -235,6 +237,10 @@ Global {632C8D1B-3293-4D02-9ED1-0CB191619334}.Debug|Any CPU.Build.0 = Debug|Any CPU {632C8D1B-3293-4D02-9ED1-0CB191619334}.Release|Any CPU.ActiveCfg = Release|Any CPU {632C8D1B-3293-4D02-9ED1-0CB191619334}.Release|Any CPU.Build.0 = Release|Any CPU + {1BE960DA-4F54-4128-AEAE-993960DB9455}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1BE960DA-4F54-4128-AEAE-993960DB9455}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1BE960DA-4F54-4128-AEAE-993960DB9455}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1BE960DA-4F54-4128-AEAE-993960DB9455}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -276,6 +282,7 @@ Global {95C3B040-BD5A-4A80-B5D4-26CAA21B4829} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} {7130EC5B-C987-487A-B319-E91B6D03F5BF} = {1987061F-8970-4018-8D58-6932961C9EB4} {632C8D1B-3293-4D02-9ED1-0CB191619334} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} + {1BE960DA-4F54-4128-AEAE-993960DB9455} = {1987061F-8970-4018-8D58-6932961C9EB4} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D5B2E7E3-B727-40A1-BE68-7BAC9B9DE2FE} diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 026a0e1fb..746d5aa21 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -15,7 +15,7 @@ public void Initialize(GeneratorInitializationContext context) public void Execute(GeneratorExecutionContext context) { var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance, context.CancellationToken); - var options = GeneratorOptions.Default; + var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); var outputs = compiler.GenerateAsync(context.Compilation, options).GetAwaiter().GetResult(); var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxContextReceiver!; diff --git a/src/MagicOnion.GeneratorCore/GeneratorOptions.cs b/src/MagicOnion.GeneratorCore/GeneratorOptions.cs index d0f3669e8..bbd1b2858 100644 --- a/src/MagicOnion.GeneratorCore/GeneratorOptions.cs +++ b/src/MagicOnion.GeneratorCore/GeneratorOptions.cs @@ -17,6 +17,13 @@ public record GeneratorOptions { public const string JsonFileName = "MagicOnionClientGeneratorOptions.json"; + static readonly JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions() + { + AllowTrailingCommas = true, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + ReadCommentHandling = JsonCommentHandling.Skip, + }; + public static GeneratorOptions Default { get; } = new GeneratorOptions(); /// @@ -55,15 +62,13 @@ public static GeneratorOptions Create(ImmutableArray additionalT var content = optionsJsonFile.GetText(cancellationToken)?.ToString(); if (content != null) { - options = JsonSerializer.Deserialize(content, new JsonSerializerOptions() - { - AllowTrailingCommas = true, - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - ReadCommentHandling = JsonCommentHandling.Skip, - }) ?? Default; + options = JsonSerializer.Deserialize(content, jsonSerializerOptions) ?? Default; } } return options; } + + public string ToJson() + => JsonSerializer.Serialize(this, jsonSerializerOptions); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs index d5ffdcf34..a22381329 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs @@ -36,10 +36,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -79,10 +79,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -123,10 +123,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -165,10 +165,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -205,10 +205,10 @@ public class MyNestedGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -350,12 +350,12 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } - } + } """; await MagicOnionSourceGeneratorVerifier.RunAsync(source); @@ -394,10 +394,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -437,10 +437,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -479,10 +479,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -521,10 +521,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -561,10 +561,10 @@ public class MyNestedGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -708,10 +708,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -754,10 +754,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -799,10 +799,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -843,10 +843,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -887,10 +887,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -929,10 +929,10 @@ public class MyNestedGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs index d0ed4a7ee..88fd7a158 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs @@ -36,10 +36,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -78,10 +78,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -118,10 +118,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -157,10 +157,10 @@ public class MyNestedGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -296,10 +296,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -338,10 +338,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -379,10 +379,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -419,10 +419,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -459,10 +459,10 @@ public class MyGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; @@ -498,10 +498,10 @@ public class MyNestedGenericObject // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) namespace MessagePack.Formatters.TempProject { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs index 02353f9c0..6b640464d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs @@ -5,6 +5,23 @@ namespace MagicOnion.Client.SourceGenerator.Tests; public class GeneratorOptionsTest { + [Fact] + public async Task Default() + { + var source = """ + using MagicOnion; + + namespace MyApplication1; + + public interface IGreeterService : IService + { + UnaryResult HelloAsync(string name, int age); + } + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + [Fact] public async Task DisableAutoRegister() { @@ -43,6 +60,7 @@ public interface IGreeterService : IService public async Task MessagePackFormatterNamespace() { var source = """ + using System; using MagicOnion; namespace MyApplication1 @@ -57,15 +75,15 @@ public class MyGenericObject {} namespace __UserDefined__.MessagePack.Formatters.MyApplication1 { - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> + public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter> { - public void Serialize(ref MessagePackWriter writer, global::MyApplication1.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::MyApplication1.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyApplication1.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); + public global::MyApplication1.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source, options: GeneratorOptions.Default with { MessagePackFormatterNamespace = "__UserDefined__.MessagePack.Formatters." }); + await MagicOnionSourceGeneratorVerifier.RunAsync(source, options: GeneratorOptions.Default with { MessagePackFormatterNamespace = "__UserDefined__.MessagePack.Formatters" }); } [Fact] diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d013f540a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..9a2a12c41 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs new file mode 100644 index 000000000..0e3ddaf1f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MyApplication1 +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs index 5ac8ea1d0..8f061d2b1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs @@ -66,10 +66,10 @@ internal static object GetFormatter(Type t) } } /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] + [__Generated__.Resolvers.Preserve] internal static class TypeHints { - [MagicOnion.Resolvers.Preserve] + [__Generated__.Resolvers.Preserve] internal static void Register() { _ = MagicOnionResolver.Instance.GetFormatter>(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index e36d0a8ea..5126771c5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -41,6 +41,12 @@ public static async Task RunAsync(IEnumerable<(string Path, string Content)> tes { }, }; + + if (options is not null) + { + test.TestState.AdditionalFiles.Add((GeneratorOptions.JsonFileName, options.ToJson())); + } + test.TestState.Sources.AddRange(testSourceCodes.Select(x => (x.Path, SourceText.From(x.Content, Encoding.UTF8, SourceHashAlgorithm.Sha1)))); await test.RunAsync(); } @@ -85,7 +91,7 @@ void AddGeneratedReferenceSources() { var prefix = $"{typeof(Test).Assembly.GetName().Name}.Resources.{Path.GetFileNameWithoutExtension(testFile)}.{testMethod}."; - foreach (var resName in typeof(Test).Assembly.GetManifestResourceNames()) + foreach (var resName in typeof(Test).Assembly.GetManifestResourceNames().OrderBy(x => x)) { if (!resName.StartsWith(prefix)) continue; From 48f30de33acac49e23a6eb5ab3338db51fd9626d Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 5 Oct 2023 18:14:22 +0900 Subject: [PATCH 06/66] Incremental Source Generator --- MagicOnion.sln | 1 + NuGet.Config | 15 +- .../MagicOnionClientSourceGenerator.cs | 30 +- .../MagicOnionCompiler.cs | 9 +- .../Collector/MagicOnionTypeInfoTest.cs | 743 +++++++++++++ .../Collector/MethodCollectorServicesTest.cs | 982 ++++++++++++++++++ .../MethodCollectorStreamingHubsTest.cs | 783 ++++++++++++++ .../SerializationInfoCollectorTest.cs | 453 ++++++++ .../CompilationHelper.cs | 34 + ...cOnion.Client.SourceGenerator.Tests.csproj | 6 +- .../MagicOnionGeneratorTestOutputLogger.cs | 22 + .../MagicOnionSourceGeneratorVerifier.cs | 11 +- 12 files changed, 3068 insertions(+), 21 deletions(-) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MethodCollectorServicesTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MethodCollectorStreamingHubsTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs diff --git a/MagicOnion.sln b/MagicOnion.sln index 0fa03ec05..170c18bd5 100644 --- a/MagicOnion.sln +++ b/MagicOnion.sln @@ -21,6 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{15598FE3-2 .gitignore = .gitignore Directory.Build.props = Directory.Build.props LICENSE = LICENSE + NuGet.Config = NuGet.Config README.md = README.md EndProjectSection EndProject diff --git a/NuGet.Config b/NuGet.Config index 3f0e00340..d680640d3 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,6 +1,17 @@  - + + - \ No newline at end of file + + + + + + + + + + + diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 746d5aa21..e8b61cbe6 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -1,9 +1,12 @@ +using System.Threading; using MagicOnion.Generator; +using MagicOnion.Generator.CodeAnalysis; using MagicOnion.Generator.Internal; using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator; +#if LEGACY_SOURCE_GENERATOR [Generator(LanguageNames.CSharp)] public class MagicOnionClientSourceGenerator : ISourceGenerator { @@ -14,9 +17,9 @@ public void Initialize(GeneratorInitializationContext context) public void Execute(GeneratorExecutionContext context) { - var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance, context.CancellationToken); + var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); - var outputs = compiler.GenerateAsync(context.Compilation, options).GetAwaiter().GetResult(); + var outputs = compiler.Generate(context.Compilation, options, context.CancellationToken); var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxContextReceiver!; @@ -25,11 +28,26 @@ public void Execute(GeneratorExecutionContext context) context.AddSource(output.Path, output.Source); } } - - class SyntaxContextReceiver : ISyntaxContextReceiver +} +#else +[Generator(LanguageNames.CSharp)] +public class MagicOnionClientSourceGenerator : IIncrementalGenerator +{ + public void Initialize(IncrementalGeneratorInitializationContext context) { - public void OnVisitSyntaxNode(GeneratorSyntaxContext context) + var options = context.AdditionalTextsProvider.Collect().Select(static (x, cancellationToken) => GeneratorOptions.Create(x, cancellationToken)); + + var compilationAndOptions = context.CompilationProvider.Combine(options); + + context.RegisterSourceOutput(compilationAndOptions, static (sourceProductionContext, pair) => { - } + var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); + var generated = compiler.Generate(pair.Item1, pair.Item2, sourceProductionContext.CancellationToken); + foreach (var (path, source) in generated) + { + sourceProductionContext.AddSource(path, source); + } + }); } } +#endif diff --git a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs b/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs index 37a4c3746..171706368 100644 --- a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs +++ b/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs @@ -17,18 +17,13 @@ public class MagicOnionCompiler static readonly Encoding NoBomUtf8 = new UTF8Encoding(false); readonly IMagicOnionGeneratorLogger logger; - readonly CancellationToken cancellationToken; - public MagicOnionCompiler(IMagicOnionGeneratorLogger logger, CancellationToken cancellationToken) + public MagicOnionCompiler(IMagicOnionGeneratorLogger logger) { this.logger = logger; - this.cancellationToken = cancellationToken; } - public async Task> GenerateAsync( - Compilation compilation, - GeneratorOptions options - ) + public IReadOnlyList<(string Path, string Source)> Generate(Compilation compilation, GeneratorOptions options, CancellationToken cancellationToken) { var outputs = new List<(string Path, string Source)>(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs new file mode 100644 index 000000000..0b4f2d190 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs @@ -0,0 +1,743 @@ +using MagicOnion.Generator.CodeAnalysis; +using Microsoft.CodeAnalysis; + +namespace MagicOnion.Client.SourceGenerator.Tests.Collector; + +public class MagicOnionTypeInfoTest +{ + [Fact] + public void Simple() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.Create("System", "String"); + + // Assert + var fullName = typeInfo.FullName; + fullName.Should().Be("global::System.String"); + typeInfo.IsArray.Should().BeFalse(); + typeInfo.IsEnum.Should().BeFalse(); + typeInfo.ElementType.Should().BeNull(); + typeInfo.UnderlyingType.Should().BeNull(); + } + + [Fact] + public void CreateArray() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateArray("System", "String"); + + // Assert + var fullName = typeInfo.FullName; + fullName.Should().Be("global::System.String[]"); + typeInfo.IsArray.Should().BeTrue(); + typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.Create("System", "String")); + } + + [Fact] + public void CreateArray_Generics() + { + // Arrange & Act + // Tuple[] + var typeInfo = MagicOnionTypeInfo.CreateArray("System", "Tuple", + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.CreateValueType("System", "Int32")), MagicOnionTypeInfo.Create("System", "String")); + + // Assert + var fullName = typeInfo.FullName; + fullName.Should().Be("global::System.Tuple[]"); + typeInfo.IsArray.Should().BeTrue(); + } + + [Fact] + public void CreateArray_JaggedArray() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("System", "String[]")); + + // Assert + var fullName = typeInfo.FullName; + fullName.Should().Be("global::System.String[][]"); + typeInfo.IsArray.Should().BeTrue(); + typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.Create("System", "String[]")); // NOTE: Currently, MOTypeInfo doesn't handle an element type for jagged array. + } + + [Fact] + public void CreateArray_Rank() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("System", "String"), 3); + + // Assert + var fullName = typeInfo.FullName; + fullName.Should().Be("global::System.String[,,]"); + typeInfo.ArrayRank.Should().Be(3); + typeInfo.IsArray.Should().BeTrue(); + } + + [Fact] + public void CreateFromType() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + + // Assert + typeInfo.FullName.Should().Be("global::System.String"); + typeInfo.IsEnum.Should().BeFalse(); + typeInfo.IsArray.Should().BeFalse(); + typeInfo.IsValueType.Should().BeFalse(); + } + + [Fact] + public void CreateFromType_ValueType() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + + // Assert + typeInfo.FullName.Should().Be("global::System.Byte"); + typeInfo.IsEnum.Should().BeFalse(); + typeInfo.IsArray.Should().BeFalse(); + typeInfo.IsValueType.Should().BeTrue(); + } + + [Fact] + public void CreateFromType_Generics() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateFromType>(); + + // Assert + typeInfo.FullName.Should().Be("global::System.Tuple"); + typeInfo.GenericArguments.Should().HaveCount(2); + typeInfo.IsEnum.Should().BeFalse(); + typeInfo.IsArray.Should().BeFalse(); + } + + [Fact] + public void CreateFromType_Array() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + + // Assert + typeInfo.FullName.Should().Be("global::System.Int32[]"); + typeInfo.GenericArguments.Should().BeEmpty(); + typeInfo.IsEnum.Should().BeFalse(); + typeInfo.IsArray.Should().BeTrue(); + typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.CreateValueType("System", "Int32")); + typeInfo.ArrayRank.Should().Be(1); + } + + [Fact] + public void CreateFromType_Array_Rank() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + + // Assert + typeInfo.FullName.Should().Be("global::System.Int32[,,]"); + typeInfo.GenericArguments.Should().BeEmpty(); + typeInfo.IsEnum.Should().BeFalse(); + typeInfo.IsArray.Should().BeTrue(); + typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.CreateValueType("System", "Int32")); + typeInfo.ArrayRank.Should().Be(3); + } + + [Fact] + public void CreateFromType_Enum() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + + // Assert + typeInfo.FullName.Should().Be("global::System.DayOfWeek"); + typeInfo.GenericArguments.Should().BeEmpty(); + typeInfo.IsEnum.Should().BeTrue(); + typeInfo.IsValueType.Should().BeTrue(); + typeInfo.UnderlyingType.Should().Be(MagicOnionTypeInfo.CreateValueType("System", "Int32")); + typeInfo.IsArray.Should().BeFalse(); + typeInfo.ElementType.Should().BeNull(); + } + + [Fact] + public void CreateFromType_Enum_Array() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + + // Assert + typeInfo.FullName.Should().Be("global::System.DayOfWeek[]"); + typeInfo.GenericArguments.Should().BeEmpty(); + typeInfo.IsEnum.Should().BeFalse(); + typeInfo.UnderlyingType.Should().BeNull(); + typeInfo.IsArray.Should().BeTrue(); + typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.CreateEnum("System", "DayOfWeek", MagicOnionTypeInfo.CreateValueType("System", "Int32"))); + typeInfo.ElementType.IsEnum.Should().BeTrue(); + typeInfo.ElementType.IsArray.Should().BeFalse(); + typeInfo.ElementType.IsValueType.Should().BeTrue(); + typeInfo.ElementType.UnderlyingType.Should().Be(MagicOnionTypeInfo.CreateValueType("System", "Int32")); + } + + [Fact] + public void CreateValueType() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateValueType("MyNamespace", "MyStruct", new [] { MagicOnionTypeInfo.CreateFromType() }); + + // Assert + typeInfo.IsValueType.Should().BeTrue(); + } + + [Fact] + public void CreateEnum() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType()); + } + + [Fact] + public void WithGenericArgument() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.Create("System.Collections.Generic", "Dictionary", + MagicOnionTypeInfo.Create("System", "String"), + MagicOnionTypeInfo.CreateValueType("System", "Int32")); + + // Assert + var fullName = typeInfo.FullName; + var genericArguments = typeInfo.GenericArguments; + fullName.Should().Be("global::System.Collections.Generic.Dictionary"); + genericArguments.Should().Equal(MagicOnionTypeInfo.Create("System", "String"), MagicOnionTypeInfo.CreateValueType("System", "Int32")); + } + + [Fact] + public void WithGenericArgumentNested() + { + // Arrange & Act + var typeInfo = MagicOnionTypeInfo.Create("System.Collections.Generic", "Dictionary", + MagicOnionTypeInfo.Create("System", "String"), + MagicOnionTypeInfo.Create("System", "Tuple", + MagicOnionTypeInfo.CreateValueType("System", "Double"), + MagicOnionTypeInfo.CreateValueType("System", "Byte"))); + + // Assert + var fullName = typeInfo.FullName; + var genericArgumentsNested = typeInfo.GenericArguments[1].GenericArguments; + fullName.Should().Be("global::System.Collections.Generic.Dictionary>"); + genericArgumentsNested.Should().Equal(MagicOnionTypeInfo.CreateValueType("System", "Double"), MagicOnionTypeInfo.CreateValueType("System", "Byte")); + } + + [Fact] + public void FromSymbol_Global() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + public class MyClass { } + "); + var symbols = compilation.GlobalNamespace.GetTypeMembers("MyClass"); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0]); + + // Assert + typeInfo.Namespace.Should().BeEmpty(); + typeInfo.Name.Should().Be("MyClass"); + typeInfo.FullName.Should().Be("global::MyClass"); + } + + [Fact] + public void FromSymbol_Namespaced() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public class MyClass { } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "MyClass", SymbolFilter.Type).OfType().ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0]); + + // Assert + typeInfo.Namespace.Should().Be("MyNamespace"); + typeInfo.Name.Should().Be("MyClass"); + typeInfo.FullName.Should().Be("global::MyNamespace.MyClass"); + } + + [Fact] + public void FromSymbol_Nullable() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public class MyClass + { + public System.Tuple FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Should().Be(MagicOnionTypeInfo.Create("System", "Tuple", + MagicOnionTypeInfo.CreateValueType("System", "Nullable", + MagicOnionTypeInfo.CreateValueType("System", "Boolean")), + MagicOnionTypeInfo.CreateValueType("System", "Nullable", + MagicOnionTypeInfo.CreateValueType("System", "Int64")))); + } + + [Fact] + public void FromSymbol_ValueType() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public class MyClass + { + public int FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Should().Be(MagicOnionTypeInfo.CreateValueType( "System", "Int32", Array.Empty())); + typeInfo.IsValueType.Should().BeTrue(); + typeInfo.IsEnum.Should().BeFalse(); + } + + [Fact] + public void FromSymbol_Enum() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public enum MyEnum : byte + { + A, B, C + } + public class MyClass + { + public MyEnum FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Should().Be(MagicOnionTypeInfo.CreateEnum( "MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateValueType("System", "Byte"))); + } + + [Fact] + public void FromSymbol_Enum_Array() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public enum MyEnum : byte + { + A, B, C + } + public class MyClass + { + public MyEnum[] FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Should().Be(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.CreateEnum( "MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateValueType("System", "Byte")))); + } + + [Fact] + public void FromSymbol_Enum_Generics() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public enum MyEnum : byte + { + A, B, C + } + public class MyClass + { + public System.Tuple FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Should().Be(MagicOnionTypeInfo.Create("System", "Tuple", + MagicOnionTypeInfo.CreateValueType("System", "Int32"), + MagicOnionTypeInfo.CreateEnum( "MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateValueType("System", "Byte")))); + } + + [Fact] + public void FromSymbol_Array() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public class MyClass + { + public int[] FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Should().Be(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.CreateValueType("System", "Int32"))); + } + + [Fact] + public void FromSymbol_JaggedArray() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public class MyClass + { + public int[][] FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Should().Be(MagicOnionTypeInfo.CreateArray("System", "Int32[]")); + } + + [Fact] + public void FromSymbol_ArrayGenerics() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public class MyClass + { + public System.Tuple[] FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Should().Be(MagicOnionTypeInfo.CreateArray("System", "Tuple", + MagicOnionTypeInfo.CreateValueType("System", "Int32"), + MagicOnionTypeInfo.Create("System", "String"))); + } + + [Fact] + public void FromSymbol_ArrayRank() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public class MyClass + { + public string[,,] FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Should().Be(MagicOnionTypeInfo.CreateArray("System", "String", Array.Empty(), 3)); + } + + [Fact] + public void FromSymbol_Generics() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + public class MyClass + { + public System.Collections.Generic.List FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Namespace.Should().Be("System.Collections.Generic"); + typeInfo.Name.Should().Be("List"); + typeInfo.GenericArguments.Should().HaveCount(1); + typeInfo.GenericArguments[0].Should().Be(MagicOnionTypeInfo.Create("System", "String")); + typeInfo.FullName.Should().Be("global::System.Collections.Generic.List"); + } + + [Fact] + public void FromSymbol_Generics_Nested() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + using System; + using System.Collections.Generic; + public class MyClass + { + public List> FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Namespace.Should().Be("System.Collections.Generic"); + typeInfo.Name.Should().Be("List"); + typeInfo.GenericArguments.Should().HaveCount(1); + typeInfo.GenericArguments[0].Should().Be(MagicOnionTypeInfo.Create("System", "Tuple", MagicOnionTypeInfo.CreateValueType("System", "Int32"), MagicOnionTypeInfo.Create("System", "String"))); + typeInfo.FullName.Should().Be("global::System.Collections.Generic.List>"); + } + + [Fact] + public void FromSymbol_NamedValueTuple() + { + // Arrange + var (compilation, semModel) = CompilationHelper.Create(@" + namespace MyNamespace + { + using System; + using System.Collections.Generic; + public class MyClass + { + public (string Name, int Age) FieldA; + } + } + "); + var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) + .OfType() + .ToArray(); + + // Act + var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); + + // Assert + typeInfo.Namespace.Should().Be("System"); + typeInfo.Name.Should().Be("ValueTuple"); + typeInfo.GenericArguments.Should().HaveCount(2); + typeInfo.GenericArguments[0].Should().Be(MagicOnionTypeInfo.Create("System", "String")); + typeInfo.GenericArguments[1].Should().Be(MagicOnionTypeInfo.CreateValueType("System", "Int32")); + typeInfo.FullName.Should().Be("global::System.ValueTuple"); + } + + [Fact] + public void ToDisplay_Short() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + // Act + var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Short); + // Assert + formatted.Should().Be("Nil"); + } + + [Fact] + public void ToDisplay_Short_Nested() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType>(); + // Act + var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Short); + // Assert + formatted.Should().Be("Tuple"); + } + + [Fact] + public void ToDisplay_FullyQualified() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + // Act + var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.FullyQualified); + // Assert + formatted.Should().Be("global::MessagePack.Nil"); + } + + [Fact] + public void ToDisplay_FullyQualified_Nested() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType>(); + // Act + var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.FullyQualified); + // Assert + formatted.Should().Be("global::System.Tuple"); + } + + [Fact] + public void ToDisplay_Namespace() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + // Act + var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace); + // Assert + formatted.Should().Be("MessagePack.Nil"); + } + + [Fact] + public void ToDisplay_OpenGenerics() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType>(); + // Act + var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.OpenGenerics); + // Assert + formatted.Should().Be("Tuple<,>"); + } + + [Fact] + public void ToDisplay_WithoutGenericArguments() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType>(); + // Act + var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.WithoutGenericArguments); + // Assert + formatted.Should().Be("Tuple"); + } + + [Fact] + public void EnumerateDependentTypes_Array() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + // Act + var types = typeInfo.EnumerateDependentTypes().ToArray(); + // Assert + types.Should().Equal(MagicOnionTypeInfo.CreateFromType()); + } + + [Fact] + public void EnumerateDependentTypes_Enum_Array() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType(); + // Act + var types = typeInfo.EnumerateDependentTypes().ToArray(); + // Assert + types.Should().Equal(MagicOnionTypeInfo.CreateFromType()); + } + + [Fact] + public void EnumerateDependentTypes_Enum_Generics() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType>(); + // Act + var types = typeInfo.EnumerateDependentTypes().ToArray(); + // Assert + types.Should().Equal(MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()); + } + + [Fact] + public void EnumerateDependentTypes_Generics() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType>(); + // Act + var types = typeInfo.EnumerateDependentTypes().ToArray(); + // Assert + types.Should().Equal(MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()); + } + + [Fact] + public void EnumerateDependentTypes_Generics_Nested() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType>>>(); + // Act + var types = typeInfo.EnumerateDependentTypes().ToArray(); + // Assert + types.Should().Equal( + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType>>(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType()); + } + + [Fact] + public void GetGenericTypeDefinition() + { + // Arrange + var typeInfo = MagicOnionTypeInfo.CreateFromType>(); + // Act + var genericDefinition = typeInfo.GetGenericTypeDefinition(); + // Assert + genericDefinition.Should().Be(MagicOnionTypeInfo.Create("System", "ValueTuple", Array.Empty(), true)); + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MethodCollectorServicesTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MethodCollectorServicesTest.cs new file mode 100644 index 000000000..a5da56ac5 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MethodCollectorServicesTest.cs @@ -0,0 +1,982 @@ +#if FALSE +using MagicOnion.Generator.CodeAnalysis; +using Microsoft.CodeAnalysis; +using Xunit.Abstractions; + +namespace MagicOnion.Client.SourceGenerator.Tests.Collector; + +public class MethodCollectorServicesTest +{ + readonly ITestOutputHelper testOutputHelper; + + public MethodCollectorServicesTest(ITestOutputHelper testOutputHelper) + { + this.testOutputHelper = testOutputHelper; + } + + [Fact] + public void FileScopedNamespace() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + UnaryResult NilAsync(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(1); + // UnaryResult NilAsync(); + serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("NilAsync"); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + } + + [Fact] + public void IfDirectives() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +[GenerateIfDirective(""DEBUG || CONST_1 || CONST_2"")] +public interface IMyService : IService +{ + [GenerateDefineDebug] + UnaryResult MethodA(); + + [GenerateIfDirective(""CONST_3"")] + UnaryResult MethodB(); + + UnaryResult MethodC(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeTrue(); + serviceCollection.Services[0].IfDirectiveCondition.Should().Be("DEBUG || CONST_1 || CONST_2"); + serviceCollection.Services[0].Methods[0].HasIfDirectiveCondition.Should().BeTrue(); + serviceCollection.Services[0].Methods[0].IfDirectiveCondition.Should().Be("DEBUG"); + serviceCollection.Services[0].Methods[1].HasIfDirectiveCondition.Should().BeTrue(); + serviceCollection.Services[0].Methods[1].IfDirectiveCondition.Should().Be("CONST_3"); + serviceCollection.Services[0].Methods[2].HasIfDirectiveCondition.Should().BeFalse(); + } + + [Fact] + public void Ignore_Method() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + UnaryResult MethodA(); + + [Ignore] + UnaryResult MethodB(); + + UnaryResult MethodC(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].Methods.Should().HaveCount(2); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Services[0].Methods[1].MethodName.Should().Be("MethodC"); + } + + [Fact] + public void Ignore_Interface() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +[Ignore] +public interface IMyService : IService +{ + UnaryResult MethodA(); + + UnaryResult MethodB(); + + UnaryResult MethodC(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().BeEmpty(); + } + + [Fact] + public void Unary_NonGenericResult() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult MethodA(); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + } + + [Fact] + public void Unary_Array() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult[]> MethodA(Tuple[] arg1); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType[]>()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType[]>()); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType[]>>()); + } + + [Fact] + public void Unary_Nullable() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult MethodA(Tuple arg1); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + } + + [Fact] + public void Unary_Parameter_Zero_ReturnNil() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult MethodA(); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(1); + // UnaryResult MethodA(); + serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + } + + + [Fact] + public void Unary_Parameter_Zero_ReturnValue() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult MethodA(); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(1); + // UnaryResult MethodA(); + serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + } + + [Fact] + public void Unary_Parameter_One_ReturnNil() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult MethodA(string arg1); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(1); + // UnaryResult MethodA(string arg1); + serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + } + + [Fact] + public void Unary_Parameter_Many_ReturnNil() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult MethodA(string arg1, int arg2); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(1); + // UnaryResult MethodA(string arg1, int arg2); + serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[1].Type.Should().Be( MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + } + + + [Fact] + public void Unary_HasDefaultValue() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult MethodA(string arg1 = ""Hello"", int arg2 = 1234, long arg3 = default, string arg4 = default); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Services[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[0].HasExplicitDefaultValue.Should().BeTrue(); + serviceCollection.Services[0].Methods[0].Parameters[0].DefaultValue.Should().Be("\"Hello\""); + serviceCollection.Services[0].Methods[0].Parameters[1].Type.Should().Be( MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[1].DefaultValue.Should().Be("1234"); + serviceCollection.Services[0].Methods[0].Parameters[1].HasExplicitDefaultValue.Should().BeTrue(); + serviceCollection.Services[0].Methods[0].Parameters[2].Type.Should().Be( MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[2].DefaultValue.Should().Be("0"); + serviceCollection.Services[0].Methods[0].Parameters[2].HasExplicitDefaultValue.Should().BeTrue(); + serviceCollection.Services[0].Methods[0].Parameters[3].Type.Should().Be( MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[3].DefaultValue.Should().Be("null"); + serviceCollection.Services[0].Methods[0].Parameters[3].HasExplicitDefaultValue.Should().BeTrue(); + } + + [Fact] + public void Unary_Methods() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult NilAsync(); + UnaryResult StringAsync(); + UnaryResult OneParameter(string arg1); + UnaryResult TwoParameter(string arg1, int arg2); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(4); + } + + [Fact] + public void Unary_InvalidReturnType_ServerStreamingResult() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult> MethodA(); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act & Assert + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + Assert.Throws(() => collector.Collect(compilation)); + } + + [Fact] + public void Unary_InvalidReturnType_ClientStreamingResult() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult> MethodA(); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act & Assert + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + Assert.Throws(() => collector.Collect(compilation)); + } + + [Fact] + public void Unary_InvalidReturnType_DuplexStreamingResult() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + UnaryResult> MethodA(); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act & Assert + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + Assert.Throws(() => collector.Collect(compilation)); + } + + [Fact] + public void UnsupportedType() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace +{ + public interface IMyService : IService + { + void MethodA(); + } +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act & Assert + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + Assert.Throws(() => collector.Collect(compilation)); + } + + [Fact] + public void ServerStreaming_Parameter_Zero() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + Task> ServerStreaming(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(1); + // Task> ServerStreamingNoArg(); + serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("ServerStreaming"); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>>()); + } + + [Fact] + public void ServerStreaming_Parameter_One() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + Task> ServerStreaming(string arg1); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(1); + // Task> ServerStreamingNoArg(); + serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("ServerStreaming"); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>>()); + } + + [Fact] + public void ServerStreaming_Parameter_Many() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + Task> ServerStreaming(string arg1, int arg2); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(1); + // Task> ServerStreamingNoArg(); + serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("ServerStreaming"); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); + serviceCollection.Services[0].Methods[0].Parameters[1].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters[1].Name.Should().Be("arg2"); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>>()); + } + + [Fact] + public void ServerStreaming_ShouldNotBeTask() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + ServerStreamingResult ServerStreaming(string arg1, int arg2); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act & Assert + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + Assert.Throws(() => collector.Collect(compilation)); + } + + + [Fact] + public void DuplexStreaming() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + Task> MethodA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(1); + // Task> MethodA(); + serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>>()); + } + + [Fact] + public void DuplexStreaming_ParameterNotSupported() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + Task> MethodA(string arg1); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act & Assert + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + Assert.Throws(() => collector.Collect(compilation)); + } + + [Fact] + public void ClientStreaming() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + Task> MethodA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().HaveCount(1); + serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); + serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Services[0].Methods.Should().HaveCount(1); + // Task> MethodA(); + serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); + serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); + serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>>()); + } + + [Fact] + public void ClientStreaming_ParameterNotSupported() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + Task> MethodA(string arg1); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act & Assert + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + Assert.Throws(() => collector.Collect(compilation)); + } + + [Fact] + public void GlobalUsings() + { + // Arrange + var source = @" +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyService : IService +{ + UnaryResult NilAsync(); + UnaryResult StringAsync(); + UnaryResult OneParameter(string arg1); + UnaryResult TwoParameter(string arg1, int arg2); + Task> ServerStreaming(string arg1, int arg2); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(new TemporaryProjectWorkareaOptions() + { + TargetFramework = "netstandard2.0", + }); + tempWorkspace.AddFileToProject("Usings.cs", """ + global using System; + global using System.Threading.Tasks; + global using System.Collections.Generic; + """); + tempWorkspace.AddFileToProject("IMyService.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); + var serviceCollection = collector.Collect(compilation); + + // Assert + compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); + serviceCollection.Should().NotBeNull(); + serviceCollection.Services.Should().NotBeEmpty(); + } +} +#endif diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MethodCollectorStreamingHubsTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MethodCollectorStreamingHubsTest.cs new file mode 100644 index 000000000..f83b9aec8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MethodCollectorStreamingHubsTest.cs @@ -0,0 +1,783 @@ +#if FALSE +using MagicOnion.Generator.CodeAnalysis; + +namespace MagicOnion.Client.SourceGenerator.Tests.Collector; + +public class MethodCollectorStreamingHubsTest +{ + [Fact] + public void FileScopedNamespace() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().HaveCount(1); + serviceCollection.Services.Should().BeEmpty(); + serviceCollection.Hubs[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyHub")); + serviceCollection.Hubs[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Hubs[0].Methods.Should().HaveCount(1); + // Task MethodA(); + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Hubs[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Hubs[0].Methods[0].Parameters.Should().BeEmpty(); + serviceCollection.Hubs[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + } + + [Fact] + public void Ignore_Method() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(); + + [Ignore] + Task MethodB(); + + Task MethodC(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().HaveCount(1); + serviceCollection.Services.Should().BeEmpty(); + serviceCollection.Hubs[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyHub")); + serviceCollection.Hubs[0].HasIfDirectiveCondition.Should().BeFalse(); + serviceCollection.Hubs[0].Methods.Should().HaveCount(2); + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[1].MethodName.Should().Be("MethodC"); + } + + [Fact] + public void Ignore_Interface() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +[Ignore] +public interface IMyHub : IStreamingHub +{ + Task MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().BeEmpty(); + serviceCollection.Services.Should().BeEmpty(); + serviceCollection.Hubs.Should().BeEmpty(); + } + + [Fact] + public void Parameter_Zero() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + // Task MethodA(); + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Hubs[0].Methods[0].Parameters.Should().BeEmpty(); + } + + [Fact] + public void Parameter_One() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(int arg1); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + // Task MethodA(); + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Hubs[0].Methods[0].Parameters.Should().HaveCount(1); + serviceCollection.Hubs[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); + serviceCollection.Hubs[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Hubs[0].Methods[0].Parameters[0].HasExplicitDefaultValue.Should().BeFalse(); + serviceCollection.Hubs[0].Methods[0].Parameters[0].DefaultValue.Should().Be("default(int)"); + } + + [Fact] + public void Parameter_Many() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(int arg1, string arg2); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + // Task MethodA(); + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + serviceCollection.Hubs[0].Methods[0].Parameters.Should().HaveCount(2); + serviceCollection.Hubs[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); + serviceCollection.Hubs[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Hubs[0].Methods[0].Parameters[0].HasExplicitDefaultValue.Should().BeFalse(); + serviceCollection.Hubs[0].Methods[0].Parameters[0].DefaultValue.Should().Be("default(int)"); + serviceCollection.Hubs[0].Methods[0].Parameters[1].Name.Should().Be("arg2"); + serviceCollection.Hubs[0].Methods[0].Parameters[1].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Hubs[0].Methods[0].Parameters[1].HasExplicitDefaultValue.Should().BeFalse(); + serviceCollection.Hubs[0].Methods[0].Parameters[1].DefaultValue.Should().Be("default(string)"); + } + + + [Fact] + public void Parameter_HasDefaultValue() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(int arg1, string arg2 = ""DEFAULT""); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + // Task MethodA(); + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + serviceCollection.Hubs[0].Methods[0].Parameters.Should().HaveCount(2); + serviceCollection.Hubs[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); + serviceCollection.Hubs[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Hubs[0].Methods[0].Parameters[0].HasExplicitDefaultValue.Should().BeFalse(); + serviceCollection.Hubs[0].Methods[0].Parameters[0].DefaultValue.Should().Be("default(int)"); + serviceCollection.Hubs[0].Methods[0].Parameters[1].Name.Should().Be("arg2"); + serviceCollection.Hubs[0].Methods[0].Parameters[1].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); + serviceCollection.Hubs[0].Methods[0].Parameters[1].HasExplicitDefaultValue.Should().BeTrue(); + serviceCollection.Hubs[0].Methods[0].Parameters[1].DefaultValue.Should().Be("\"DEFAULT\""); + } + + [Fact] + public void HubId_Implicit() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().HaveCount(1); + serviceCollection.Hubs[0].Methods.Should().HaveCount(1); + // Task MethodA(); + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].HubId.Should().Be(1497325507); + // void EventA(); + serviceCollection.Hubs[0].Receiver.Methods[0].MethodName.Should().Be("EventA"); + serviceCollection.Hubs[0].Receiver.Methods[0].HubId.Should().Be(842297178); + } + + [Fact] + public void HubId_Explicit() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +using MagicOnion.Server.Hubs; // for MethodIdAttribute + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + [MethodId(12345)] + Task MethodA(); +} + +public interface IMyHubReceiver +{ + [MethodId(67890)] + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().HaveCount(1); + serviceCollection.Hubs[0].Methods.Should().HaveCount(1); + // Task MethodA(); + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].HubId.Should().Be(12345); + // void EventA(); + serviceCollection.Hubs[0].Receiver.Methods[0].MethodName.Should().Be("EventA"); + serviceCollection.Hubs[0].Receiver.Methods[0].HubId.Should().Be(67890); + } + + [Fact] + public void ReturnType_NotSupported_Void() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + void MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act & Assert + var collector = new MethodCollector(); + var ex = Assert.Throws(() => collector.Collect(compilation)); + } + + [Fact] + public void ReturnType_NotSupported_NotTaskOfT() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + string MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act & Assert + var collector = new MethodCollector(); + var ex = Assert.Throws(() => collector.Collect(compilation)); + } + + [Fact] + public void ReturnType_Task() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); + serviceCollection.Hubs[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_Task); + } + + [Fact] + public void ReturnType_TaskOfT() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_String); + serviceCollection.Hubs[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + } + + [Fact] + public void ReturnType_ValueTask() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + ValueTask MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); + serviceCollection.Hubs[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_ValueTask); + } + + [Fact] + public void ReturnType_ValueTaskOfT() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + ValueTask MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); + serviceCollection.Hubs[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_String); + serviceCollection.Hubs[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + } + + [Fact] + public void Receiver() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(); +} + +public interface IMyHubReceiver +{ + void EventA(); + void EventB(Nil nil); + void EventC(string arg1, int arg2); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Should().NotBeNull(); + serviceCollection.Hubs.Should().HaveCount(1); + serviceCollection.Hubs[0].Methods.Should().HaveCount(1); + serviceCollection.Hubs[0].Receiver.Should().NotBeNull(); + serviceCollection.Hubs[0].Receiver.Methods.Should().HaveCount(3); + // void EventA(); + serviceCollection.Hubs[0].Receiver.Methods[0].MethodName.Should().Be("EventA"); + serviceCollection.Hubs[0].Receiver.Methods[0].Parameters.Should().BeEmpty(); + serviceCollection.Hubs[0].Receiver.Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); + serviceCollection.Hubs[0].Receiver.Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); + serviceCollection.Hubs[0].Receiver.Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_Void); + // void EventB(Nil nil); + serviceCollection.Hubs[0].Receiver.Methods[1].MethodName.Should().Be("EventB"); + serviceCollection.Hubs[0].Receiver.Methods[1].Parameters.Should().HaveCount(1); + serviceCollection.Hubs[0].Receiver.Methods[1].RequestType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); + serviceCollection.Hubs[0].Receiver.Methods[1].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); + serviceCollection.Hubs[0].Receiver.Methods[1].MethodReturnType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_Void); + // void EventB(Nil nil); + serviceCollection.Hubs[0].Receiver.Methods[2].MethodName.Should().Be("EventC"); + serviceCollection.Hubs[0].Receiver.Methods[2].Parameters.Should().HaveCount(2); + serviceCollection.Hubs[0].Receiver.Methods[2].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); + serviceCollection.Hubs[0].Receiver.Methods[2].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); + serviceCollection.Hubs[0].Receiver.Methods[2].MethodReturnType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_Void); + } + + [Fact] + public void Receiver_NonVoidReturnType() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(); +} + +public interface IMyHubReceiver +{ + int EventA(); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act & Assert + var collector = new MethodCollector(); + var ex = Assert.Throws(() => collector.Collect(compilation)); + } + + [Fact] + public void IfDirectives() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +[GenerateIfDirective(""DEBUG || CONST_1 || CONST_2"")] +public interface IMyHub : IStreamingHub +{ + [GenerateDefineDebug] + Task MethodA(); + [GenerateIfDirective(""CONST_3"")] + Task MethodB(); + Task MethodC(); +} + +public interface IMyHubReceiver +{ + void EventA(); + void EventB(Nil nil); + void EventC(string arg1, int arg2); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Hubs[0].HasIfDirectiveCondition.Should().BeTrue(); + serviceCollection.Hubs[0].IfDirectiveCondition.Should().Be("DEBUG || CONST_1 || CONST_2"); + serviceCollection.Hubs[0].Methods[0].HasIfDirectiveCondition.Should().BeTrue(); + serviceCollection.Hubs[0].Methods[0].IfDirectiveCondition.Should().Be("DEBUG"); + serviceCollection.Hubs[0].Methods[1].HasIfDirectiveCondition.Should().BeTrue(); + serviceCollection.Hubs[0].Methods[1].IfDirectiveCondition.Should().Be("CONST_3"); + serviceCollection.Hubs[0].Methods[2].HasIfDirectiveCondition.Should().BeFalse(); + } + + [Fact] + public void IfDirectives_Receiver() + { + // Arrange + var source = @" +using System; +using System.Threading.Tasks; +using MagicOnion; +using MessagePack; + +namespace MyNamespace; + +public interface IMyHub : IStreamingHub +{ + Task MethodA(); + Task MethodB(); + Task MethodC(); +} + +[GenerateIfDirective(""DEBUG || CONST_1 || CONST_2"")] +public interface IMyHubReceiver +{ + [GenerateDefineDebug] + void EventA(); + [GenerateIfDirective(""CONST_3"")] + void EventB(Nil nil); + void EventC(string arg1, int arg2); +} +"; + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyHub.cs", source); + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + + // Act + var collector = new MethodCollector(); + var serviceCollection = collector.Collect(compilation); + + // Assert + serviceCollection.Hubs[0].Receiver.HasIfDirectiveCondition.Should().BeTrue(); + serviceCollection.Hubs[0].Receiver.IfDirectiveCondition.Should().Be("DEBUG || CONST_1 || CONST_2"); + serviceCollection.Hubs[0].Receiver.Methods[0].HasIfDirectiveCondition.Should().BeTrue(); + serviceCollection.Hubs[0].Receiver.Methods[0].IfDirectiveCondition.Should().Be("DEBUG"); + serviceCollection.Hubs[0].Receiver.Methods[1].HasIfDirectiveCondition.Should().BeTrue(); + serviceCollection.Hubs[0].Receiver.Methods[1].IfDirectiveCondition.Should().Be("CONST_3"); + serviceCollection.Hubs[0].Receiver.Methods[2].HasIfDirectiveCondition.Should().BeFalse(); + } +} +#endif diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs new file mode 100644 index 000000000..a84dc606b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs @@ -0,0 +1,453 @@ +using MagicOnion.Generator.CodeAnalysis; +using Xunit.Abstractions; + +namespace MagicOnion.Client.SourceGenerator.Tests.Collector; + +public class SerializationInfoCollectorTest +{ + readonly ITestOutputHelper testOutputHelper; + + public SerializationInfoCollectorTest(ITestOutputHelper testOutputHelper) + { + this.testOutputHelper = testOutputHelper; + } + + [Fact] + public void NonGenerics() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject"), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject"), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject"), new string[] { "CONST_2 || DEBUG"}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject"), new string[] { "CONST_3" }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Enums.Should().BeEmpty(); + serializationInfoCollection.Generics.Should().BeEmpty(); + serializationInfoCollection.TypeHints.Should().HaveCount(3); + } + + [Fact] + public void Nullable() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject")), new string[] { }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Enums.Should().BeEmpty(); + serializationInfoCollection.Generics.Should().HaveCount(2); + serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.NullableFormatter()"); + serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.NullableFormatter()"); + serializationInfoCollection.TypeHints.Should().HaveCount(4); // Non-nullable + Nullable + } + + [Fact] + public void Generics_MergeIfDirectives() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_2 || DEBUG"}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_3" }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Generics.Should().HaveCount(2); + serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.MyGenericObjectFormatter()"); + // NOTE: If there is a type without `if` condition, then merged if condition is always empty. (The type is always required by consumers) + serializationInfoCollection.Generics[0].IfDirectiveConditions.Should().BeEmpty(); + serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.YetAnotherGenericObjectFormatter()"); + serializationInfoCollection.Generics[1].IfDirectiveConditions.Should().HaveCount(2); + serializationInfoCollection.Generics[1].IfDirectiveConditions.Should().BeEquivalentTo("CONST_2 || DEBUG", "CONST_3"); + serializationInfoCollection.TypeHints.Should().HaveCount(4); // int, string, MyGenericObject, YetAnotherGenericObject + } + + [Fact] + public void Generics_ManyTypeArguments() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Generics.Should().HaveCount(2); + serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.MyGenericObjectFormatter()"); + serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.MyGenericObjectFormatter()"); + serializationInfoCollection.TypeHints.Should().HaveCount(5); // string, int, long, MyGenericObject, MyGenericObject + } + + [Fact] + public void Enum() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType()), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnumConditional", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType())), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnumConditional", MagicOnionTypeInfo.CreateFromType())), new string[] { "CONST_2" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "YetAnotherEnum", MagicOnionTypeInfo.CreateFromType())), new string[] { }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Generics.Should().HaveCount(3); + serializationInfoCollection.Enums.Should().HaveCount(3); + serializationInfoCollection.Enums[0].Namespace.Should().Be("MyNamespace"); + serializationInfoCollection.Enums[0].Name.Should().Be("MyEnum"); + serializationInfoCollection.Enums[0].GetFormatterNameWithConstructorArgs().Should().Be("MyEnumFormatter()"); + serializationInfoCollection.Enums[0].HasIfDirectiveConditions.Should().BeFalse(); + serializationInfoCollection.Enums[1].Namespace.Should().Be("MyNamespace"); + serializationInfoCollection.Enums[1].Name.Should().Be("MyEnumConditional"); + serializationInfoCollection.Enums[1].GetFormatterNameWithConstructorArgs().Should().Be("MyEnumConditionalFormatter()"); + serializationInfoCollection.Enums[1].IfDirectiveConditions.Should().BeEquivalentTo("CONST_1", "CONST_2"); + serializationInfoCollection.Enums[2].Namespace.Should().Be("MyNamespace"); + serializationInfoCollection.Enums[2].Name.Should().Be("YetAnotherEnum"); + serializationInfoCollection.Enums[2].GetFormatterNameWithConstructorArgs().Should().Be("YetAnotherEnumFormatter()"); + serializationInfoCollection.Enums[2].HasIfDirectiveConditions.Should().BeFalse(); + serializationInfoCollection.TypeHints.Should().HaveCount(6); // MyEnum, MyEnumConditional, YetAnotherEnum, MyGenericObject, MyGenericObject, MyGenericObject + } + + [Fact] + public void KnownTypes_SkipBuiltInGenericTypes() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType?>(), new string[] {}), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Generics.Should().BeEmpty(); + serializationInfoCollection.TypeHints.Should().HaveCount(3); // byte, ArraySegment, Nullable> + } + + [Fact] + public void KnownTypes_Array_SkipBuiltInTypes() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MessagePack", "Nil")), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector2")), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector3")), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector4")), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Quaternion")), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Color")), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Bounds")), new string[] {}), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Rect")), new string[] {}), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Generics.Should().BeEmpty(); + serializationInfoCollection.TypeHints.Should().HaveCount(46); + } + + [Fact] + public void KnownTypes_Array_NonBuiltIn() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 2), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 3), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 4), new string[] { "CONST_1" }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Generics.Should().HaveCount(4); + serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ArrayFormatter()"); + serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TwoDimensionalArrayFormatter()"); + serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ThreeDimensionalArrayFormatter()"); + serializationInfoCollection.Generics[3].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.FourDimensionalArrayFormatter()"); + serializationInfoCollection.TypeHints.Should().HaveCount(5); // MyObject, MyObject[], MyObject[,], MyObject[,,], MyObject[,,,] + } + + [Fact] + public void KnownTypes_Generics() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "List",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IList",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyList",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "Dictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IDictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyDictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "ICollection",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyCollection",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IEnumerable",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "KeyValuePair",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Linq", "ILookup",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Linq", "IGrouping",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Generics.Should().HaveCount(12); + serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ListFormatter()"); + serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceListFormatter2()"); + serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceReadOnlyListFormatter()"); + serializationInfoCollection.Generics[3].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.DictionaryFormatter()"); + serializationInfoCollection.Generics[4].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceDictionaryFormatter()"); + serializationInfoCollection.Generics[5].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter()"); + serializationInfoCollection.Generics[6].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceCollectionFormatter2()"); + serializationInfoCollection.Generics[7].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter()"); + serializationInfoCollection.Generics[8].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceEnumerableFormatter()"); + serializationInfoCollection.Generics[9].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.KeyValuePairFormatter()"); + serializationInfoCollection.Generics[10].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceLookupFormatter()"); + serializationInfoCollection.Generics[11].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceGroupingFormatter()"); + serializationInfoCollection.TypeHints.Should().HaveCount(14); + } + + [Fact] + public void KnownTypes_Nullable() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Enums.Should().BeEmpty(); + serializationInfoCollection.Generics.Should().BeEmpty(); + serializationInfoCollection.TypeHints.Should().HaveCount(26); + } + + [Fact] + public void KnownTypes_ValueTuple() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Generics.Should().HaveCount(8); + serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); + serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); + serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); + serializationInfoCollection.Generics[3].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); + serializationInfoCollection.Generics[4].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); + serializationInfoCollection.Generics[5].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); + serializationInfoCollection.Generics[6].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); + serializationInfoCollection.Generics[7].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); + serializationInfoCollection.TypeHints.Should().HaveCount(8 + 8); + } + + [Fact] + public void KnownTypes_Tuple() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Generics.Should().HaveCount(8); + serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); + serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); + serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); + serializationInfoCollection.Generics[3].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); + serializationInfoCollection.Generics[4].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); + serializationInfoCollection.Generics[5].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); + serializationInfoCollection.Generics[6].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); + serializationInfoCollection.Generics[7].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); + } + + [Fact] + public void DynamicArgumentTuple() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Generics.Should().HaveCount(2); + serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int64))"); + serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32))"); + serializationInfoCollection.TypeHints.Should().HaveCount(5); // string, long, int, DynamicArgumentTuple, DynamicArgumentTuple + } + + [Fact] + public void UserDefinedMessagePackSerializerFormattersNamespace() + { + // Arrange + var userDefinedMessagePackFormattersNamespace = "MyFormatters"; + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(userDefinedMessagePackFormattersNamespace)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Enums.Should().BeEmpty(); + serializationInfoCollection.Generics.Should().HaveCount(3); + serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.NullableFormatter()"); + serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int64))"); + serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MyFormatters.MyNamespace.MyGenericObjectFormatter()"); + } + + [Fact] + public void UserDefinedMessagePackSerializerFormattersNamespace_NotSpecified() + { + // Arrange + var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var types = new[] + { + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), + new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { }), + }; + + // Act + var serializationInfoCollection = collector.Collect(types); + + // Assert + serializationInfoCollection.Should().NotBeNull(); + serializationInfoCollection.Enums.Should().BeEmpty(); + serializationInfoCollection.Generics.Should().HaveCount(3); + serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.NullableFormatter()"); + serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int64))"); + serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.MyGenericObjectFormatter()"); + } +} + +file static class SerializationFormatterRegisterInfoExtensions +{ + public static string GetFormatterNameWithConstructorArgs(this ISerializationFormatterRegisterInfo serializationFormatterRegisterInfo) + => serializationFormatterRegisterInfo.FormatterName + serializationFormatterRegisterInfo.FormatterConstructorArgs; +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs new file mode 100644 index 000000000..dd5fa8cc5 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs @@ -0,0 +1,34 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public static class CompilationHelper +{ + public static (Compilation Compilation, SemanticModel SemanticModel) Create(string code) + { + var syntaxTree = SyntaxFactory.ParseSyntaxTree(code, CSharpParseOptions.Default); + var assemblyName = Guid.NewGuid().ToString(); + var refAsmDir = Path.GetDirectoryName(typeof(object).Assembly.Location)!; + var references = new MetadataReference[] + { + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Private.CoreLib.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.Extensions.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Collections.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Linq.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Console.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Memory.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "netstandard.dll")), + MetadataReference.CreateFromFile(typeof(object).Assembly.Location), + }; + var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); + + var compilation = CSharpCompilation.Create(assemblyName, new [] { syntaxTree }, references, compilationOptions); + if (compilation.GetDiagnostics().Any(x => x.Severity == DiagnosticSeverity.Error)) + { + throw new InvalidOperationException("Failed to compile the source code. \n" + string.Join(Environment.NewLine, compilation.GetDiagnostics().Select(x => x.ToString()))); + } + return (compilation, compilation.GetSemanticModel(syntaxTree)); + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj index caac74e20..f7fa28c4d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj @@ -12,7 +12,6 @@ - @@ -25,6 +24,11 @@ + + + + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs new file mode 100644 index 000000000..1ba6fd4e4 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs @@ -0,0 +1,22 @@ +using MagicOnion.Generator.Internal; +using Xunit.Abstractions; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public class MagicOnionGeneratorTestOutputLogger : IMagicOnionGeneratorLogger +{ + readonly ITestOutputHelper outputHelper; + + public MagicOnionGeneratorTestOutputLogger(ITestOutputHelper outputHelper) + { + this.outputHelper = outputHelper; + } + +#if FALSE + public void Trace(string message) => outputHelper.WriteLine(message); +#else + public void Trace(string message) {} +#endif + public void Information(string message) => outputHelper.WriteLine(message); + public void Error(string message, Exception? exception = null) => outputHelper.WriteLine(message); +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index 5126771c5..08a241aca 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -108,9 +108,9 @@ protected override Task RunImplAsync(CancellationToken cancellationToken) return base.RunImplAsync(cancellationToken); } - protected override async Task GetProjectCompilationAsync(Project project, IVerifier verifier, CancellationToken cancellationToken) + protected override async Task<(Compilation compilation, ImmutableArray generatorDiagnostics)> GetProjectCompilationAsync(Project project, IVerifier verifier, CancellationToken cancellationToken) { - var compilation = await base.GetProjectCompilationAsync(project, verifier, cancellationToken); + var (compilation, diagnostics) = await base.GetProjectCompilationAsync(project, verifier, cancellationToken); var resourceDirectory = Path.Combine(Path.GetDirectoryName(testFile)!, "Resources", Path.GetFileNameWithoutExtension(testFile), testMethod); foreach (var syntaxTree in compilation.SyntaxTrees.Skip(project.DocumentIds.Count)) @@ -118,12 +118,13 @@ protected override async Task GetProjectCompilationAsync(Project pr WriteTreeToDiskIfNecessary(syntaxTree, resourceDirectory, ""); } - return compilation; + return (compilation, diagnostics); } - protected override IEnumerable GetSourceGenerators() + + protected override IEnumerable GetSourceGenerators() { - yield return new MagicOnionClientSourceGenerator(); + yield return typeof(MagicOnionClientSourceGenerator); } [Conditional("WRITE_EXPECTED")] From 6cb2169bd650bf4f41cfb4eba5a30f36dbb91b52 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Fri, 6 Oct 2023 12:52:15 +0900 Subject: [PATCH 07/66] WIP --- .../MagicOnion.Client.SourceGenerator.csproj | 5 +- .../MagicOnionClientSourceGenerator.cs | 3 +- .../CodeAnalysis/MethodCollector.cs | 6 +- .../CodeAnalysis/ReferenceSymbols.cs | 98 ++++--------------- .../MagicOnion.GeneratorCore.csproj | 5 +- .../CompilationHelper.cs | 3 + .../RunTest.cs | 49 ++++++++++ 7 files changed, 81 insertions(+), 88 deletions(-) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index c6c976337..91fe0bb12 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -16,10 +16,7 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index e8b61cbe6..21ab0a6ae 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -35,7 +35,8 @@ public class MagicOnionClientSourceGenerator : IIncrementalGenerator { public void Initialize(IncrementalGeneratorInitializationContext context) { - var options = context.AdditionalTextsProvider.Collect().Select(static (x, cancellationToken) => GeneratorOptions.Create(x, cancellationToken)); + var options = context.AdditionalTextsProvider.Collect().Select(static (x, cancellationToken) => GeneratorOptions.Create(x, cancellationToken)).WithTrackingName("GeneratorOptions"); + var referenceSymbols = context.CompilationProvider.Select(static (x, cancellationToken) => ReferenceSymbols.TryCreate(x, out var rs) ? rs : default).WithTrackingName("ReferenceSymbols"); var compilationAndOptions = context.CompilationProvider.Combine(options); diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs index 4b055af79..e764322a0 100644 --- a/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs @@ -292,7 +292,11 @@ public MethodCollectorContext(ReferenceSymbols referenceSymbols, IReadOnlyList x.TypeKind == TypeKind.Interface) .Where(x => diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/ReferenceSymbols.cs b/src/MagicOnion.GeneratorCore/CodeAnalysis/ReferenceSymbols.cs index afc5d5a7a..bc0e13948 100644 --- a/src/MagicOnion.GeneratorCore/CodeAnalysis/ReferenceSymbols.cs +++ b/src/MagicOnion.GeneratorCore/CodeAnalysis/ReferenceSymbols.cs @@ -1,91 +1,33 @@ -using System.Reflection; -using MagicOnion.Generator.Internal; using Microsoft.CodeAnalysis; namespace MagicOnion.Generator.CodeAnalysis; -public class ReferenceSymbols +public record ReferenceSymbols { - public readonly INamedTypeSymbol Void; - public readonly INamedTypeSymbol Task; - public readonly INamedTypeSymbol TaskOfT; - public readonly INamedTypeSymbol UnaryResult; - public readonly INamedTypeSymbol ClientStreamingResult; - public readonly INamedTypeSymbol ServerStreamingResult; - public readonly INamedTypeSymbol DuplexStreamingResult; - public readonly INamedTypeSymbol IServiceMarker; - public readonly INamedTypeSymbol IService; - public readonly INamedTypeSymbol IStreamingHubMarker; - public readonly INamedTypeSymbol IStreamingHub; - public readonly INamedTypeSymbol MethodIdAttribute; + public INamedTypeSymbol IServiceMarker { get; init; } + public INamedTypeSymbol IService { get; init; } + public INamedTypeSymbol IStreamingHubMarker { get; init; } + public INamedTypeSymbol IStreamingHub { get; init; } - public ReferenceSymbols(Compilation compilation, IMagicOnionGeneratorLogger logger) + public static bool TryCreate(Compilation compilation, out ReferenceSymbols referenceSymbols) { - INamedTypeSymbol GetTypeSymbolOrThrow(string name, SpecialType type = SpecialType.None, bool required = true) + if (compilation.GetTypeByMetadataName("MagicOnion.IServiceMarker") is { } symbolIServiceMarker && + compilation.GetTypeByMetadataName("MagicOnion.IService`1") is { } symbolIService && + compilation.GetTypeByMetadataName("MagicOnion.IStreamingHubMarker") is { } symbolIStreamingHubMarker && + compilation.GetTypeByMetadataName("MagicOnion.IStreamingHub`2") is { } symbolIStreamingHub + ) { - logger.Trace($"[{nameof(ReferenceSymbols)}] GetTypeSymbolOrThrow: {name}; type={type}; required={required}"); - var symbol = compilation.GetTypeByMetadataName(name); - logger.Trace($"[{nameof(ReferenceSymbols)}] GetTypeByMetadataName: {name}; Symbol={symbol}"); - - if (symbol == null) - { - symbol = GetWellKnownType(name); - logger.Trace($"[{nameof(ReferenceSymbols)}] GetWellKnownType: {name}; Symbol={symbol}"); - } - if (symbol == null) - { - symbol = GetSpecialType(type); - logger.Trace($"[{nameof(ReferenceSymbols)}] GetSpecialType: {name}; Symbol={symbol}"); - } - - if (symbol == null) + referenceSymbols = new ReferenceSymbols() { - var message = $"Unable to get metadata of {name}. Please check that there is a reference to MagicOnion.Abstractions or try to run `dotnet restore`."; - logger.Error(message); - if (required) throw new InvalidOperationException(message); - } - - return symbol; - } - - var getTypeFromMetadataName = typeof(Compilation).Assembly - .GetType("Microsoft.CodeAnalysis.WellKnownTypes") - .GetMethod("GetTypeFromMetadataName", BindingFlags.Static | BindingFlags.Public); - - var getWellKnownType = compilation.GetType() - .GetMethod("CommonGetWellKnownType", BindingFlags.Instance | BindingFlags.NonPublic); - - INamedTypeSymbol GetWellKnownType(string name) - { - var wellKnownType = getTypeFromMetadataName?.Invoke(null, new object[] { name }); - var instance = wellKnownType != null && (int)wellKnownType > 0 - ? getWellKnownType?.Invoke(compilation, new[] { wellKnownType }) - : null; - - // Roslyn returns PENamedTypeSymbol which is not convertable to INamedTypeSymbol - // https://github.com/dotnet/roslyn/blob/main/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs#L2408 - return instance as INamedTypeSymbol; - } - - INamedTypeSymbol GetSpecialType(SpecialType type) - { - return type != SpecialType.None - ? compilation.GetSpecialType(type) - : null; + IService = symbolIService, + IServiceMarker = symbolIServiceMarker, + IStreamingHub = symbolIStreamingHub, + IStreamingHubMarker = symbolIStreamingHubMarker, + }; + return true; } - logger.Trace($"[{nameof(ReferenceSymbols)}] Resolving well-known reference symbols..."); - Void = GetTypeSymbolOrThrow("System.Void", SpecialType.System_Void); - Task = GetTypeSymbolOrThrow("System.Threading.Tasks.Task", required: false); - TaskOfT = GetTypeSymbolOrThrow("System.Threading.Tasks.Task`1", required: false); - UnaryResult = GetTypeSymbolOrThrow("MagicOnion.UnaryResult`1"); - ClientStreamingResult = GetTypeSymbolOrThrow("MagicOnion.ClientStreamingResult`2"); - DuplexStreamingResult = GetTypeSymbolOrThrow("MagicOnion.DuplexStreamingResult`2"); - ServerStreamingResult = GetTypeSymbolOrThrow("MagicOnion.ServerStreamingResult`1"); - IStreamingHubMarker = GetTypeSymbolOrThrow("MagicOnion.IStreamingHubMarker"); - IServiceMarker = GetTypeSymbolOrThrow("MagicOnion.IServiceMarker"); - IStreamingHub = GetTypeSymbolOrThrow("MagicOnion.IStreamingHub`2"); - IService = GetTypeSymbolOrThrow("MagicOnion.IService`1"); - MethodIdAttribute = GetTypeSymbolOrThrow("MagicOnion.Server.Hubs.MethodIdAttribute"); + referenceSymbols = default; + return false; } } diff --git a/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj b/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj index f39d95b5f..e3723329c 100644 --- a/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj +++ b/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj @@ -14,10 +14,7 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs index dd5fa8cc5..acfce9dfd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs @@ -21,6 +21,9 @@ public static (Compilation Compilation, SemanticModel SemanticModel) Create(stri MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Memory.dll")), MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "netstandard.dll")), MetadataReference.CreateFromFile(typeof(object).Assembly.Location), + MetadataReference.CreateFromFile(typeof(MagicOnion.IService<>).Assembly.Location), // Abstractions + MetadataReference.CreateFromFile(typeof(MagicOnion.Client.MagicOnionClient).Assembly.Location), // Client + MetadataReference.CreateFromFile(typeof(MagicOnion.GrpcMethodHelper).Assembly.Location), // Shared }; var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs new file mode 100644 index 000000000..12b00902d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs @@ -0,0 +1,49 @@ +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +// ref: https://www.meziantou.net/testing-roslyn-incremental-source-generators.htm + +public class RunTest +{ + [Fact] + public async Task RunTest1() + { + var (compilation, semanticModel) = CompilationHelper.Create(""" + using System; + using MagicOnion; + + namespace TempProject; + + public interface IMyService : IService + { + UnaryResult HelloAsync(string name, int age); + } + """); + var sourceGenerator = new MagicOnionClientSourceGenerator(); + + GeneratorDriver driver = CSharpGeneratorDriver.Create( + generators: new[] { sourceGenerator.AsSourceGenerator() }, + driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true) + ); + + // Run generator for the first time. + driver = driver.RunGenerators(compilation); + var resultFirstTime = driver.GetRunResult().Results; + + // Modify syntax trees + compilation = compilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText("//comment")); + + // Run generator again. + driver = driver.RunGenerators(compilation); + + // Generator's output should be unchanged. + var result = driver.GetRunResult().Results.Single(); + var allOutputReason = result.TrackedOutputSteps.SelectMany(x => x.Value).SelectMany(x => x.Outputs); + Assert.Collection(allOutputReason, x => Assert.Equal(IncrementalStepRunReason.Unchanged, x.Reason)); + + var generatedTrees = driver.GetRunResult().GeneratedTrees; + } +} From 7f7d9a80136de2e4d18dc468ca8addea4ae64b1d Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 10 Oct 2023 10:13:26 +0900 Subject: [PATCH 08/66] WIP --- .../MagicOnionClientSourceGenerator.cs | 47 ++++++++++++++++-- .../CodeAnalysis/MethodCollector.cs | 38 +++++++++----- .../MagicOnionCompiler.cs | 9 ++-- .../RunTest.cs | 49 +++++++++++++++---- 4 files changed, 112 insertions(+), 31 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 21ab0a6ae..8c30ba4c4 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; using System.Threading; using MagicOnion.Generator; using MagicOnion.Generator.CodeAnalysis; @@ -35,20 +38,54 @@ public class MagicOnionClientSourceGenerator : IIncrementalGenerator { public void Initialize(IncrementalGeneratorInitializationContext context) { - var options = context.AdditionalTextsProvider.Collect().Select(static (x, cancellationToken) => GeneratorOptions.Create(x, cancellationToken)).WithTrackingName("GeneratorOptions"); - var referenceSymbols = context.CompilationProvider.Select(static (x, cancellationToken) => ReferenceSymbols.TryCreate(x, out var rs) ? rs : default).WithTrackingName("ReferenceSymbols"); + var options = context.AdditionalTextsProvider.Collect() + .Select(static (x, cancellationToken) => GeneratorOptions.Create(x, cancellationToken)) + .WithTrackingName("mo_GeneratorOptions"); + var referenceSymbols = context.CompilationProvider + .Select(static (x, cancellationToken) => ReferenceSymbols.TryCreate(x, out var rs) ? rs : default) + .WithTrackingName("mo_ReferenceSymbols"); + var interfaceSymbols = context.CompilationProvider + .SelectMany(static (x, cancellationToken) => GetNamedTypeSymbols(x)) + .Where(x => x.TypeKind == TypeKind.Interface) + .WithComparer(SymbolEqualityComparer.Default) + .Collect() + .WithTrackingName("mo_InterfaceSymbols"); - var compilationAndOptions = context.CompilationProvider.Combine(options); + var source = options + .Combine(interfaceSymbols) + .Combine(referenceSymbols) + .WithTrackingName("mo_Combined"); - context.RegisterSourceOutput(compilationAndOptions, static (sourceProductionContext, pair) => + context.RegisterSourceOutput(source, static (sourceProductionContext, pair) => { + var ((options, interfaceSymbols), referenceSymbols) = pair; var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); - var generated = compiler.Generate(pair.Item1, pair.Item2, sourceProductionContext.CancellationToken); + var generated = compiler.Generate(interfaceSymbols, referenceSymbols, options, sourceProductionContext.CancellationToken); foreach (var (path, source) in generated) { sourceProductionContext.AddSource(path, source); } }); } + + public static IEnumerable GetNamedTypeSymbols(Compilation compilation) + { + foreach (var syntaxTree in compilation.SyntaxTrees) + { + var semModel = compilation.GetSemanticModel(syntaxTree); + + foreach (var item in syntaxTree.GetRoot() + .DescendantNodes() + .Select(x => semModel.GetDeclaredSymbol(x)) + .Where(x => x != null)) + { + var namedType = item as INamedTypeSymbol; + if (namedType != null) + { + yield return namedType; + } + } + } + } } #endif diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs index e764322a0..189e78960 100644 --- a/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs @@ -1,3 +1,4 @@ +using System.Collections.Immutable; using MagicOnion.Generator.Internal; using MagicOnion.Generator.Utils; using Microsoft.CodeAnalysis; @@ -17,9 +18,9 @@ public MethodCollector(IMagicOnionGeneratorLogger logger = null, CancellationTok this.logger = logger ?? MagicOnionGeneratorNullLogger.Instance; } - public MagicOnionServiceCollection Collect(Compilation compilation) + public MagicOnionServiceCollection Collect(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) { - var ctx = MethodCollectorContext.CreateFromCompilation(compilation, logger); + var ctx = MethodCollectorContext.CreateFromInterfaceSymbols(interfaceSymbols, referenceSymbols, logger); return new MagicOnionServiceCollection(GetStreamingHubs(ctx), GetServices(ctx)); } @@ -169,7 +170,7 @@ IReadOnlyList GetServices(MethodCollectorContext ctx) .OrderBy(x => x.ServiceType.FullName) .ToArray(); } - + MagicOnionServiceInfo.MagicOnionServiceMethodInfo CreateServiceMethodInfoFromMethodSymbol(MagicOnionTypeInfo serviceType, IMethodSymbol methodSymbol) { var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); @@ -239,7 +240,7 @@ MagicOnionServiceInfo.MagicOnionServiceMethodInfo CreateServiceMethodInfoFromMet ifDirective ); } - + static IReadOnlyList CreateParameterInfoListFromMethodSymbol(IMethodSymbol methodSymbol) => methodSymbol.Parameters.Select(x => MagicOnionMethodParameterInfo.CreateFromSymbol(x)).ToArray(); @@ -290,19 +291,32 @@ public MethodCollectorContext(ReferenceSymbols referenceSymbols, IReadOnlyList x.TypeKind == TypeKind.Interface) .Where(x => { var all = x.AllInterfaces; - if (all.Any(y => y.ApproximatelyEqual(typeReferences.IServiceMarker)) || all.Any(y => y.ApproximatelyEqual(typeReferences.IStreamingHubMarker))) + if (all.Any(y => y.ApproximatelyEqual(referenceSymbols.IServiceMarker)) || all.Any(y => y.ApproximatelyEqual(referenceSymbols.IStreamingHubMarker))) + { + return true; + } + return false; + }) + .ToArray(); + + return new MethodCollectorContext(referenceSymbols, serviceAndHubInterfaces, logger); + } + + public static MethodCollectorContext CreateFromInterfaceSymbols(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, IMagicOnionGeneratorLogger logger) + { + var serviceAndHubInterfaces = interfaceSymbols + .Where(x => x.TypeKind == TypeKind.Interface) + .Where(x => + { + var all = x.AllInterfaces; + if (all.Any(y => y.ApproximatelyEqual(referenceSymbols.IServiceMarker)) || all.Any(y => y.ApproximatelyEqual(referenceSymbols.IStreamingHubMarker))) { return true; } @@ -310,7 +324,7 @@ public static MethodCollectorContext CreateFromCompilation(Compilation compilati }) .ToArray(); - return new MethodCollectorContext(typeReferences, serviceAndHubInterfaces, logger); + return new MethodCollectorContext(referenceSymbols, serviceAndHubInterfaces, logger); } } } diff --git a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs b/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs index 171706368..c345deb19 100644 --- a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs +++ b/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs @@ -1,5 +1,6 @@ #pragma warning disable CS1998 +using System.Collections.Immutable; using System.Text; using System.Diagnostics; using System.Reflection; @@ -22,8 +23,8 @@ public MagicOnionCompiler(IMagicOnionGeneratorLogger logger) { this.logger = logger; } - - public IReadOnlyList<(string Path, string Source)> Generate(Compilation compilation, GeneratorOptions options, CancellationToken cancellationToken) + + public IReadOnlyList<(string Path, string Source)> Generate(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, GeneratorOptions options, CancellationToken cancellationToken) { var outputs = new List<(string Path, string Source)>(); @@ -70,7 +71,7 @@ public MagicOnionCompiler(IMagicOnionGeneratorLogger logger) sw.Restart(); logger.Information("Collect services and methods Start"); var collector = new MethodCollector(logger, cancellationToken); - var serviceCollection = collector.Collect(compilation); + var serviceCollection = collector.Collect(interfaceSymbols, referenceSymbols); logger.Information("Collect services and methods Complete:" + sw.Elapsed.ToString()); cancellationToken.ThrowIfCancellationRequested(); @@ -85,7 +86,7 @@ public MagicOnionCompiler(IMagicOnionGeneratorLogger logger) logger.Information("Code Generation Start"); sw.Restart(); - + var registerTemplate = new RegisterTemplate { Namespace = options.Namespace, diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs index 12b00902d..e1f13c003 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs @@ -9,19 +9,48 @@ namespace MagicOnion.Client.SourceGenerator.Tests; public class RunTest { [Fact] - public async Task RunTest1() + public async Task RunAndGenerate() { - var (compilation, semanticModel) = CompilationHelper.Create(""" - using System; - using MagicOnion; + var (compilation, semanticModel) = CompilationHelper.Create( + """ + using System; + using MagicOnion; - namespace TempProject; + namespace TempProject; - public interface IMyService : IService - { - UnaryResult HelloAsync(string name, int age); - } - """); + public interface IMyService : IService + { + UnaryResult HelloAsync(string name, int age); + } + """); + var sourceGenerator = new MagicOnionClientSourceGenerator(); + + GeneratorDriver driver = CSharpGeneratorDriver.Create( + generators: new[] { sourceGenerator.AsSourceGenerator() }, + driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true) + ); + + // Run generator for the first time. + driver = driver.RunGenerators(compilation); + var results = driver.GetRunResult().Results; + var generatedTrees = driver.GetRunResult().GeneratedTrees; + } + + [Fact] + public async Task UnchangedTest_1() + { + var (compilation, semanticModel) = CompilationHelper.Create( + """ + using System; + using MagicOnion; + + namespace TempProject; + + public interface IMyService : IService + { + UnaryResult HelloAsync(string name, int age); + } + """); var sourceGenerator = new MagicOnionClientSourceGenerator(); GeneratorDriver driver = CSharpGeneratorDriver.Create( From b300f5a9e26390403b37867cfa44e3eb364a2a4b Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 10 Oct 2023 17:22:43 +0900 Subject: [PATCH 09/66] WIP --- .../MagicOnionClientSourceGenerator.cs | 75 +++++++++--------- .../RunTest.cs | 77 +++++++++---------- 2 files changed, 77 insertions(+), 75 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 8c30ba4c4..e58544253 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -1,17 +1,17 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; -using System.Threading; using MagicOnion.Generator; using MagicOnion.Generator.CodeAnalysis; using MagicOnion.Generator.Internal; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; namespace MagicOnion.Client.SourceGenerator; #if LEGACY_SOURCE_GENERATOR [Generator(LanguageNames.CSharp)] -public class MagicOnionClientSourceGenerator : ISourceGenerator +public class MagicOnionClientSourceGeneratorRoslyn3 : ISourceGenerator { public void Initialize(GeneratorInitializationContext context) { @@ -20,18 +20,34 @@ public void Initialize(GeneratorInitializationContext context) public void Execute(GeneratorExecutionContext context) { - var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); + var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxContextReceiver!; var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); - var outputs = compiler.Generate(context.Compilation, options, context.CancellationToken); + if (ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) + { + var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); + var outputs = compiler.Generate(syntaxReceiver.Candidates.ToImmutableArray(), referenceSymbols, options, context.CancellationToken); + foreach (var output in outputs) + { + context.AddSource(output.Path, output.Source); + } + } + } +} - var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxContextReceiver!; +class SyntaxContextReceiver : ISyntaxContextReceiver +{ + public List Candidates { get; } = new(); - foreach (var output in outputs) + public void OnVisitSyntaxNode(GeneratorSyntaxContext context) + { + if (SyntaxHelper.IsCandidateInterface(context.Node)) { - context.AddSource(output.Path, output.Source); + Candidates.Add((INamedTypeSymbol)context.SemanticModel.GetDeclaredSymbol(context.Node)!); } } } + + #else [Generator(LanguageNames.CSharp)] public class MagicOnionClientSourceGenerator : IIncrementalGenerator @@ -44,48 +60,35 @@ public void Initialize(IncrementalGeneratorInitializationContext context) var referenceSymbols = context.CompilationProvider .Select(static (x, cancellationToken) => ReferenceSymbols.TryCreate(x, out var rs) ? rs : default) .WithTrackingName("mo_ReferenceSymbols"); - var interfaceSymbols = context.CompilationProvider - .SelectMany(static (x, cancellationToken) => GetNamedTypeSymbols(x)) - .Where(x => x.TypeKind == TypeKind.Interface) - .WithComparer(SymbolEqualityComparer.Default) + var interfaces = context.SyntaxProvider.CreateSyntaxProvider( + predicate: (node, ct) => SyntaxHelper.IsCandidateInterface(node), + transform: (ctx, ct) => ctx.Node) .Collect() - .WithTrackingName("mo_InterfaceSymbols"); + .WithTrackingName("mo_Interfaces"); var source = options - .Combine(interfaceSymbols) + .Combine(interfaces) .Combine(referenceSymbols) - .WithTrackingName("mo_Combined"); + .Combine(context.CompilationProvider) + .WithTrackingName("mo_Source"); context.RegisterSourceOutput(source, static (sourceProductionContext, pair) => { - var ((options, interfaceSymbols), referenceSymbols) = pair; + var (((options, interfaces), referenceSymbols), compilation) = pair; var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); - var generated = compiler.Generate(interfaceSymbols, referenceSymbols, options, sourceProductionContext.CancellationToken); + var symbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); + var generated = compiler.Generate(symbols, referenceSymbols, options, sourceProductionContext.CancellationToken); foreach (var (path, source) in generated) { sourceProductionContext.AddSource(path, source); } }); } - - public static IEnumerable GetNamedTypeSymbols(Compilation compilation) - { - foreach (var syntaxTree in compilation.SyntaxTrees) - { - var semModel = compilation.GetSemanticModel(syntaxTree); - - foreach (var item in syntaxTree.GetRoot() - .DescendantNodes() - .Select(x => semModel.GetDeclaredSymbol(x)) - .Where(x => x != null)) - { - var namedType = item as INamedTypeSymbol; - if (namedType != null) - { - yield return namedType; - } - } - } - } } #endif + +static class SyntaxHelper +{ + public static bool IsCandidateInterface(SyntaxNode node) + => node is InterfaceDeclarationSyntax interfaceDeclaration && (interfaceDeclaration.BaseList?.Types.Any() ?? false); +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs index e1f13c003..99d7895ac 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs @@ -36,43 +36,42 @@ public interface IMyService : IService var generatedTrees = driver.GetRunResult().GeneratedTrees; } - [Fact] - public async Task UnchangedTest_1() - { - var (compilation, semanticModel) = CompilationHelper.Create( - """ - using System; - using MagicOnion; - - namespace TempProject; - - public interface IMyService : IService - { - UnaryResult HelloAsync(string name, int age); - } - """); - var sourceGenerator = new MagicOnionClientSourceGenerator(); - - GeneratorDriver driver = CSharpGeneratorDriver.Create( - generators: new[] { sourceGenerator.AsSourceGenerator() }, - driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true) - ); - - // Run generator for the first time. - driver = driver.RunGenerators(compilation); - var resultFirstTime = driver.GetRunResult().Results; - - // Modify syntax trees - compilation = compilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText("//comment")); - - // Run generator again. - driver = driver.RunGenerators(compilation); - - // Generator's output should be unchanged. - var result = driver.GetRunResult().Results.Single(); - var allOutputReason = result.TrackedOutputSteps.SelectMany(x => x.Value).SelectMany(x => x.Outputs); - Assert.Collection(allOutputReason, x => Assert.Equal(IncrementalStepRunReason.Unchanged, x.Reason)); - - var generatedTrees = driver.GetRunResult().GeneratedTrees; - } + //[Fact] + //public async Task UnchangedTest_1() + //{ + // var (compilation, semanticModel) = CompilationHelper.Create( + // """ + // using System; + // using MagicOnion; + // + // namespace TempProject; + // + // public interface IMyService : IService + // { + // UnaryResult HelloAsync(string name, int age); + // } + // struct A {} + // """); + // var sourceGenerator = new MagicOnionClientSourceGenerator(); + // + // GeneratorDriver driver = CSharpGeneratorDriver.Create( + // generators: new[] { sourceGenerator.AsSourceGenerator() }, + // driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true) + // ); + // + // // Run generator for the first time. + // driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var compilation2, out _); + // var resultFirstTime = driver.GetRunResult().Results; + // + // // Modify syntax tree (editing source code) + // compilation2 = compilation2.AddSyntaxTrees(CSharpSyntaxTree.ParseText("//dummy")); + // + // // Run generator again. + // driver = driver.RunGeneratorsAndUpdateCompilation(compilation2, out var compilation3, out _); + // + // // Generator's output should be unchanged. + // var result = driver.GetRunResult().Results.Single(); + // var allOutputReason = result.TrackedOutputSteps.SelectMany(x => x.Value).SelectMany(x => x.Outputs); + // Assert.Collection(allOutputReason, x => Assert.Equal(IncrementalStepRunReason.Unchanged, x.Reason)); + //} } From 61366c91af65a2d788c102bde9664850d7607363 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 10 Oct 2023 18:34:54 +0900 Subject: [PATCH 10/66] Move sources from Generator.Core to SourceGenerator --- MagicOnion.sln | 2 +- ...cOnion.Client.SourceGenerator.Unity.csproj | 25 + .../MagicOnionClientSourceGenerator.cs | 94 ++++ .../IMagicOnionCompileDirectiveTarget.cs | 0 .../CodeAnalysis/IMagicOnionServiceInfo.cs | 0 .../MagicOnionMethodParameterInfo.cs | 2 +- .../MagicOnionServiceCollection.cs | 0 .../CodeAnalysis/MagicOnionServiceInfo.cs | 0 .../MagicOnionStreamingHubInfo.cs | 0 .../CodeAnalysis/MagicOnionTypeInfo.cs | 21 +- .../CodeAnalysis/MethodCollector.cs | 7 +- .../CodeAnalysis/MethodType.cs | 0 .../CodeAnalysis/ReferenceSymbols.cs | 28 + .../SerializationFormatterNameMapper.cs | 27 +- .../CodeAnalysis/SerializationInfo.cs | 0 .../SerializationInfoCollector.cs | 6 +- .../CodeGen/EnumTemplate.cs | 0 .../CodeGen/EnumTemplate.tt | 0 .../MagicOnionHubMethodInfoExtensions.cs | 0 ...MagicOnionMethodParameterInfoExtensions.cs | 0 .../MagicOnionServiceInfoExtensions.cs | 0 .../CodeGen/ISerializerFormatterGenerator.cs | 0 ...emoryPackFormatterRegistrationGenerator.cs | 0 .../MessagePackFormatterResolverGenerator.cs | 0 .../CodeGen/RegisterTemplate.cs | 2 +- .../CodeGen/RegisterTemplate.tt | 0 .../SerializationFormatterCodeGenContext.cs | 0 .../StaticMagicOnionClientGenerator.cs | 0 .../StaticStreamingHubClientGenerator.cs | 0 .../CodeGen/TemplatePartials.cs | 18 +- .../GeneratorOptions.cs | 0 .../Internal/FNV1A32.cs | 0 .../Internal/IMagicOnionGeneratorLogger.cs | 6 +- .../Internal/IndentedTextWriterExtensions.cs | 0 .../MagicOnion.Client.SourceGenerator.csproj | 38 +- .../MagicOnionClientSourceGenerator.cs | 47 +- .../MagicOnionCompiler.cs | 0 .../Utils/RoslynExtensions.cs | 30 +- .../Utils/TypeExtensions.cs | 0 .../CodeAnalysis/ReferenceSymbols.cs | 33 -- .../MagicOnion.GeneratorCore.csproj | 24 - .../Utils/PseudoCompilation.cs | 510 ------------------ ...cOnion.Client.SourceGenerator.Tests.csproj | 1 + 43 files changed, 251 insertions(+), 670 deletions(-) create mode 100644 src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj create mode 100644 src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/IMagicOnionServiceInfo.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/MagicOnionMethodParameterInfo.cs (96%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/MagicOnionServiceCollection.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/MagicOnionServiceInfo.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/MagicOnionStreamingHubInfo.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/MagicOnionTypeInfo.cs (93%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/MethodCollector.cs (97%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/MethodType.cs (100%) create mode 100644 src/MagicOnion.Client.SourceGenerator/CodeAnalysis/ReferenceSymbols.cs rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/SerializationFormatterNameMapper.cs (95%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/SerializationInfo.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeAnalysis/SerializationInfoCollector.cs (98%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/EnumTemplate.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/EnumTemplate.tt (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/Extensions/MagicOnionHubMethodInfoExtensions.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/Extensions/MagicOnionMethodParameterInfoExtensions.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/ISerializerFormatterGenerator.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/MemoryPackFormatterRegistrationGenerator.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/MessagePackFormatterResolverGenerator.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/RegisterTemplate.cs (99%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/RegisterTemplate.tt (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/SerializationFormatterCodeGenContext.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/StaticMagicOnionClientGenerator.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/StaticStreamingHubClientGenerator.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/CodeGen/TemplatePartials.cs (51%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/GeneratorOptions.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/Internal/FNV1A32.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/Internal/IMagicOnionGeneratorLogger.cs (83%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/Internal/IndentedTextWriterExtensions.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/MagicOnionCompiler.cs (100%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/Utils/RoslynExtensions.cs (79%) rename src/{MagicOnion.GeneratorCore => MagicOnion.Client.SourceGenerator}/Utils/TypeExtensions.cs (100%) delete mode 100644 src/MagicOnion.GeneratorCore/CodeAnalysis/ReferenceSymbols.cs delete mode 100644 src/MagicOnion.GeneratorCore/Utils/PseudoCompilation.cs diff --git a/MagicOnion.sln b/MagicOnion.sln index 170c18bd5..a41a96ea0 100644 --- a/MagicOnion.sln +++ b/MagicOnion.sln @@ -102,7 +102,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Serialization.Me EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Server.Redis.Tests", "tests\MagicOnion.Server.Redis.Tests\MagicOnion.Server.Redis.Tests.csproj", "{95C3B040-BD5A-4A80-B5D4-26CAA21B4829}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicOnion.Client.SourceGenerator", "src\MagicOnion.Client.SourceGenerator\MagicOnion.Client.SourceGenerator.csproj", "{7130EC5B-C987-487A-B319-E91B6D03F5BF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGenerator", "src\MagicOnion.Client.SourceGenerator\MagicOnion.Client.SourceGenerator.csproj", "{7130EC5B-C987-487A-B319-E91B6D03F5BF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGenerator.Tests", "tests\MagicOnion.Client.SourceGenerator.Tests\MagicOnion.Client.SourceGenerator.Tests.csproj", "{632C8D1B-3293-4D02-9ED1-0CB191619334}" EndProject diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj new file mode 100644 index 000000000..3799bdf19 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -0,0 +1,25 @@ + + + + netstandard2.0 + + latest + enable + enable + Nullable + + + true + cs + + + + + + + + + + + + diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs new file mode 100644 index 000000000..e58544253 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs @@ -0,0 +1,94 @@ +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using MagicOnion.Generator; +using MagicOnion.Generator.CodeAnalysis; +using MagicOnion.Generator.Internal; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace MagicOnion.Client.SourceGenerator; + +#if LEGACY_SOURCE_GENERATOR +[Generator(LanguageNames.CSharp)] +public class MagicOnionClientSourceGeneratorRoslyn3 : ISourceGenerator +{ + public void Initialize(GeneratorInitializationContext context) + { + context.RegisterForSyntaxNotifications(() => new SyntaxContextReceiver()); + } + + public void Execute(GeneratorExecutionContext context) + { + var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxContextReceiver!; + var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); + if (ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) + { + var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); + var outputs = compiler.Generate(syntaxReceiver.Candidates.ToImmutableArray(), referenceSymbols, options, context.CancellationToken); + foreach (var output in outputs) + { + context.AddSource(output.Path, output.Source); + } + } + } +} + +class SyntaxContextReceiver : ISyntaxContextReceiver +{ + public List Candidates { get; } = new(); + + public void OnVisitSyntaxNode(GeneratorSyntaxContext context) + { + if (SyntaxHelper.IsCandidateInterface(context.Node)) + { + Candidates.Add((INamedTypeSymbol)context.SemanticModel.GetDeclaredSymbol(context.Node)!); + } + } +} + + +#else +[Generator(LanguageNames.CSharp)] +public class MagicOnionClientSourceGenerator : IIncrementalGenerator +{ + public void Initialize(IncrementalGeneratorInitializationContext context) + { + var options = context.AdditionalTextsProvider.Collect() + .Select(static (x, cancellationToken) => GeneratorOptions.Create(x, cancellationToken)) + .WithTrackingName("mo_GeneratorOptions"); + var referenceSymbols = context.CompilationProvider + .Select(static (x, cancellationToken) => ReferenceSymbols.TryCreate(x, out var rs) ? rs : default) + .WithTrackingName("mo_ReferenceSymbols"); + var interfaces = context.SyntaxProvider.CreateSyntaxProvider( + predicate: (node, ct) => SyntaxHelper.IsCandidateInterface(node), + transform: (ctx, ct) => ctx.Node) + .Collect() + .WithTrackingName("mo_Interfaces"); + + var source = options + .Combine(interfaces) + .Combine(referenceSymbols) + .Combine(context.CompilationProvider) + .WithTrackingName("mo_Source"); + + context.RegisterSourceOutput(source, static (sourceProductionContext, pair) => + { + var (((options, interfaces), referenceSymbols), compilation) = pair; + var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); + var symbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); + var generated = compiler.Generate(symbols, referenceSymbols, options, sourceProductionContext.CancellationToken); + foreach (var (path, source) in generated) + { + sourceProductionContext.AddSource(path, source); + } + }); + } +} +#endif + +static class SyntaxHelper +{ + public static bool IsCandidateInterface(SyntaxNode node) + => node is InterfaceDeclarationSyntax interfaceDeclaration && (interfaceDeclaration.BaseList?.Types.Any() ?? false); +} diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/IMagicOnionServiceInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionServiceInfo.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/IMagicOnionServiceInfo.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionServiceInfo.cs diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionMethodParameterInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs similarity index 96% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionMethodParameterInfo.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs index 5a2f24b45..c56bbcfb6 100644 --- a/src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionMethodParameterInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs @@ -36,7 +36,7 @@ static string GetDefaultValue(IParameterSymbol p) var l = ppp.Last(); if (l.Kind == SymbolDisplayPartKind.FieldName) { - return l.Symbol.ToDisplayString(); + return l.Symbol!.ToDisplayString(); } else { diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionServiceCollection.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceCollection.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionServiceCollection.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceCollection.cs diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionServiceInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceInfo.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionServiceInfo.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceInfo.cs diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionStreamingHubInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionStreamingHubInfo.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionStreamingHubInfo.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionStreamingHubInfo.cs diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionTypeInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs similarity index 93% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionTypeInfo.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs index 78475c7b3..9ccc6ae05 100644 --- a/src/MagicOnion.GeneratorCore/CodeAnalysis/MagicOnionTypeInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs @@ -36,7 +36,7 @@ public MagicOnionTypeInfo GetGenericTypeDefinition() public bool IsArray => _subType == SubType.Array; public int ArrayRank { get; } - public MagicOnionTypeInfo ElementType { get; } + public MagicOnionTypeInfo? ElementType { get; } public string FullName => ToDisplayName(DisplayNameFormat.FullyQualified); @@ -46,7 +46,7 @@ public string FullNameOpenType public bool IsValueType => _subType == SubType.ValueType || _subType == SubType.Enum; public bool IsEnum => _subType == SubType.Enum; - public MagicOnionTypeInfo UnderlyingType { get; } + public MagicOnionTypeInfo? UnderlyingType { get; } [Flags] public enum DisplayNameFormat @@ -67,7 +67,7 @@ private enum SubType Array, } - private MagicOnionTypeInfo(string @namespace, string name, SubType subType = SubType.None, int arrayRank = 0, MagicOnionTypeInfo[] genericArguments = null, MagicOnionTypeInfo elementType = null, MagicOnionTypeInfo underlyingType = null) + private MagicOnionTypeInfo(string @namespace, string name, SubType subType = SubType.None, int arrayRank = 0, MagicOnionTypeInfo[]? genericArguments = null, MagicOnionTypeInfo? elementType = null, MagicOnionTypeInfo? underlyingType = null) { _subType = subType; Namespace = @namespace; @@ -80,7 +80,7 @@ private MagicOnionTypeInfo(string @namespace, string name, SubType subType = Sub public string ToDisplayName(DisplayNameFormat format = DisplayNameFormat.Short) => IsArray - ? $"{ElementType.ToDisplayName(format)}[{(ArrayRank > 1 ? new string(',', ArrayRank - 1) : "")}]" + ? $"{ElementType!.ToDisplayName(format)}[{(ArrayRank > 1 ? new string(',', ArrayRank - 1) : "")}]" : $"{(format.HasFlag(DisplayNameFormat.Global) ? "global::" : "")}{(format.HasFlag(DisplayNameFormat.Namespace) && !string.IsNullOrWhiteSpace(Namespace) ? Namespace + "." : "")}{Name}{((!format.HasFlag(DisplayNameFormat.WithoutGenericArguments) || format.HasFlag(DisplayNameFormat.OpenGenerics)) && GenericArguments.Any() ? "<" + (format.HasFlag(DisplayNameFormat.OpenGenerics) ? new string(',', GenericArguments.Count - 1) : string.Join(", ", GenericArguments.Select(x => x.ToDisplayName(format)))) + ">" : "")}"; public IEnumerable EnumerateDependentTypes(bool includesSelf = false) @@ -92,8 +92,9 @@ public IEnumerable EnumerateDependentTypes(bool includesSelf if (IsArray) { - yield return ElementType; - foreach (var t in ElementType.EnumerateDependentTypes()) + Debug.Assert(ElementType is not null); + yield return ElementType!; + foreach (var t in ElementType!.EnumerateDependentTypes()) { yield return t; } @@ -193,7 +194,8 @@ public static MagicOnionTypeInfo CreateFromSymbol(ITypeSymbol symbol) MagicOnionTypeInfo type; if (finalSymbol.TypeKind == TypeKind.Enum) { - type = CreateEnum(@namespace, name, CreateFromSymbol(namedTypeSymbol.EnumUnderlyingType)); + Debug.Assert(namedTypeSymbol.EnumUnderlyingType is not null); + type = CreateEnum(@namespace, name, CreateFromSymbol(namedTypeSymbol.EnumUnderlyingType!)); } else { @@ -227,10 +229,11 @@ public bool Equals(MagicOnionTypeInfo other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; + return FullName == other.FullName && /* Namespace + Name + GenericArguments + ArrayRank + ElementType */ _subType == other._subType && - ElementType == other.ElementType && - UnderlyingType == other.UnderlyingType; + ElementType! == other.ElementType! && + UnderlyingType! == other.UnderlyingType!; } public override bool Equals(object obj) diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs similarity index 97% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index 189e78960..93458b2e8 100644 --- a/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -13,9 +13,10 @@ public class MethodCollector readonly IMagicOnionGeneratorLogger logger; readonly CancellationToken cancellationToken; - public MethodCollector(IMagicOnionGeneratorLogger logger = null, CancellationToken cancellationToken = default) + public MethodCollector(IMagicOnionGeneratorLogger? logger = null, CancellationToken cancellationToken = default) { this.logger = logger ?? MagicOnionGeneratorNullLogger.Instance; + this.cancellationToken = cancellationToken; } public MagicOnionServiceCollection Collect(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) @@ -52,6 +53,7 @@ IReadOnlyList GetStreamingHubs(MethodCollectorContex return CreateHubMethodInfoFromMethodSymbol(serviceType, symbol); }) .Where(x => x is not null) + .Cast() .ToArray(); var receiverInterfaceSymbol = x.AllInterfaces.First(y => y.ConstructedFrom.ApproximatelyEqual(ctx.ReferenceSymbols.IStreamingHub)).TypeArguments[1]; @@ -67,6 +69,7 @@ IReadOnlyList GetStreamingHubs(MethodCollectorContex return new MagicOnionStreamingHubInfo(serviceType, methods, receiver, ifDirective); }) .Where(x => x is not null) + .Cast() .OrderBy(x => x.ServiceType.FullName) .ToArray(); } @@ -162,11 +165,13 @@ IReadOnlyList GetServices(MethodCollectorContext ctx) return CreateServiceMethodInfoFromMethodSymbol(serviceType, symbol); }) .Where(x => x is not null) + .Cast() .ToArray(); return new MagicOnionServiceInfo(serviceType, methods, ifDirective); }) .Where(x => x is not null) + .Cast() .OrderBy(x => x.ServiceType.FullName) .ToArray(); } diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/MethodType.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodType.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/MethodType.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodType.cs diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/ReferenceSymbols.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/ReferenceSymbols.cs new file mode 100644 index 000000000..8977ddbd9 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/ReferenceSymbols.cs @@ -0,0 +1,28 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis; + +namespace MagicOnion.Generator.CodeAnalysis; + +public record ReferenceSymbols(INamedTypeSymbol IServiceMarker, INamedTypeSymbol IService, INamedTypeSymbol IStreamingHubMarker, INamedTypeSymbol IStreamingHub) +{ + public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out ReferenceSymbols? referenceSymbols) + { + if (compilation.GetTypeByMetadataName("MagicOnion.IServiceMarker") is { } symbolIServiceMarker && + compilation.GetTypeByMetadataName("MagicOnion.IService`1") is { } symbolIService && + compilation.GetTypeByMetadataName("MagicOnion.IStreamingHubMarker") is { } symbolIStreamingHubMarker && + compilation.GetTypeByMetadataName("MagicOnion.IStreamingHub`2") is { } symbolIStreamingHub + ) + { + referenceSymbols = new ReferenceSymbols( + symbolIServiceMarker, + symbolIService, + symbolIStreamingHubMarker, + symbolIStreamingHub + ); + return true; + } + + referenceSymbols = default; + return false; + } +} diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/SerializationFormatterNameMapper.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs similarity index 95% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/SerializationFormatterNameMapper.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs index c8a04600d..6a8cecab6 100644 --- a/src/MagicOnion.GeneratorCore/CodeAnalysis/SerializationFormatterNameMapper.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs @@ -1,9 +1,12 @@ +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; + namespace MagicOnion.Generator.CodeAnalysis; public interface ISerializationFormatterNameMapper { IWellKnownSerializationTypes WellKnownTypes { get; } - bool TryMapGeneric(MagicOnionTypeInfo type, out string formatterName, out string formatterConstructorArgs); + bool TryMapGeneric(MagicOnionTypeInfo type, [NotNullWhen(true)] out string? formatterName, [NotNullWhen(true)] out string? formatterConstructorArgs); (string FormatterName, string FormatterConstructorArgs) MapArray(MagicOnionTypeInfo type); } @@ -30,7 +33,7 @@ public MessagePackFormatterNameMapper(string userDefinedFormatterNamespace) this.userDefinedFormatterNamespace = userDefinedFormatterNamespace; } - public bool TryMapGeneric(MagicOnionTypeInfo type, out string formatterName, out string formatterConstructorArgs) + public bool TryMapGeneric(MagicOnionTypeInfo type, [NotNullWhen(true)] out string? formatterName, [NotNullWhen(true)] out string? formatterConstructorArgs) { formatterName = null; formatterConstructorArgs = null; @@ -61,12 +64,13 @@ public bool TryMapGeneric(MagicOnionTypeInfo type, out string formatterName, out public (string FormatterName, string FormatterConstructorArgs) MapArray(MagicOnionTypeInfo type) { + Debug.Assert(type.ElementType is not null); return type.ArrayRank switch { - 1 => ($"global::MessagePack.Formatters.ArrayFormatter<{type.ElementType.FullName}>", "()"), - 2 => ($"global::MessagePack.Formatters.TwoDimensionalArrayFormatter<{type.ElementType.FullName}>", "()"), - 3 => ($"global::MessagePack.Formatters.ThreeDimensionalArrayFormatter<{type.ElementType.FullName}>", "()"), - 4 => ($"global::MessagePack.Formatters.FourDimensionalArrayFormatter<{type.ElementType.FullName}>", "()"), + 1 => ($"global::MessagePack.Formatters.ArrayFormatter<{type.ElementType!.FullName}>", "()"), + 2 => ($"global::MessagePack.Formatters.TwoDimensionalArrayFormatter<{type.ElementType!.FullName}>", "()"), + 3 => ($"global::MessagePack.Formatters.ThreeDimensionalArrayFormatter<{type.ElementType!.FullName}>", "()"), + 4 => ($"global::MessagePack.Formatters.FourDimensionalArrayFormatter<{type.ElementType!.FullName}>", "()"), _ => throw new IndexOutOfRangeException($"An array of rank must be less than 5. ({type.FullName})"), }; } @@ -186,7 +190,7 @@ public MemoryPackFormatterNameMapper() { } - public bool TryMapGeneric(MagicOnionTypeInfo type, out string formatterName, out string formatterConstructorArgs) + public bool TryMapGeneric(MagicOnionTypeInfo type, [NotNullWhen(true)] out string? formatterName, [NotNullWhen(true)] out string? formatterConstructorArgs) { formatterName = null; formatterConstructorArgs = null; @@ -211,12 +215,13 @@ public bool TryMapGeneric(MagicOnionTypeInfo type, out string formatterName, out public (string FormatterName, string FormatterConstructorArgs) MapArray(MagicOnionTypeInfo type) { + Debug.Assert(type.ElementType is not null); return type.ArrayRank switch { - 1 => ($"global::MemoryPack.Formatters.ArrayFormatter<{type.ElementType.FullName}>", "()"), - 2 => ($"global::MemoryPack.Formatters.TwoDimensionalArrayFormatter<{type.ElementType.FullName}>", "()"), - 3 => ($"global::MemoryPack.Formatters.ThreeDimensionalArrayFormatter<{type.ElementType.FullName}>", "()"), - 4 => ($"global::MemoryPack.Formatters.FourDimensionalArrayFormatter<{type.ElementType.FullName}>", "()"), + 1 => ($"global::MemoryPack.Formatters.ArrayFormatter<{type.ElementType!.FullName}>", "()"), + 2 => ($"global::MemoryPack.Formatters.TwoDimensionalArrayFormatter<{type.ElementType!.FullName}>", "()"), + 3 => ($"global::MemoryPack.Formatters.ThreeDimensionalArrayFormatter<{type.ElementType!.FullName}>", "()"), + 4 => ($"global::MemoryPack.Formatters.FourDimensionalArrayFormatter<{type.ElementType!.FullName}>", "()"), _ => throw new IndexOutOfRangeException($"An array of rank must be less than 5. ({type.FullName})"), }; } diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/SerializationInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfo.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/SerializationInfo.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfo.cs diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/SerializationInfoCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs similarity index 98% rename from src/MagicOnion.GeneratorCore/CodeAnalysis/SerializationInfoCollector.cs rename to src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs index 20bc45722..6d2994ba1 100644 --- a/src/MagicOnion.GeneratorCore/CodeAnalysis/SerializationInfoCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs @@ -95,18 +95,20 @@ public MagicOnionSerializationInfoCollection Collect(IEnumerable /// The string builder that generation-time code is using to assemble generated output /// - protected System.Text.StringBuilder GenerationEnvironment + public System.Text.StringBuilder GenerationEnvironment { get { diff --git a/src/MagicOnion.GeneratorCore/CodeGen/RegisterTemplate.tt b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeGen/RegisterTemplate.tt rename to src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt diff --git a/src/MagicOnion.GeneratorCore/CodeGen/SerializationFormatterCodeGenContext.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeGen/SerializationFormatterCodeGenContext.cs rename to src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs diff --git a/src/MagicOnion.GeneratorCore/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeGen/StaticMagicOnionClientGenerator.cs rename to src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs diff --git a/src/MagicOnion.GeneratorCore/CodeGen/StaticStreamingHubClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/CodeGen/StaticStreamingHubClientGenerator.cs rename to src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs diff --git a/src/MagicOnion.GeneratorCore/CodeGen/TemplatePartials.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs similarity index 51% rename from src/MagicOnion.GeneratorCore/CodeGen/TemplatePartials.cs rename to src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs index 9419c7229..cc28b1d87 100644 --- a/src/MagicOnion.GeneratorCore/CodeGen/TemplatePartials.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs @@ -2,22 +2,16 @@ namespace MagicOnion.Generator.CodeGen; -public partial class HubTemplate -{ - public string Namespace { get; set; } - public IReadOnlyList Hubs { get; set; } -} - public partial class RegisterTemplate { - public string Namespace { get; set; } - public bool DisableAutoRegisterOnInitialize { get; set; } - public IReadOnlyList Services { get; set; } - public IReadOnlyList Hubs { get; set; } + public string Namespace { get; init; } = default!; + public bool DisableAutoRegisterOnInitialize { get; init; } = default!; + public IReadOnlyList Services { get; init; } = default!; + public IReadOnlyList Hubs { get; init; } = default!; } public partial class EnumTemplate { - public string Namespace { get; set; } - public IReadOnlyList EnumSerializationInfos { get; set; } + public string Namespace { get; init; } = default!; + public IReadOnlyList EnumSerializationInfos { get; init; } = default!; } diff --git a/src/MagicOnion.GeneratorCore/GeneratorOptions.cs b/src/MagicOnion.Client.SourceGenerator/GeneratorOptions.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/GeneratorOptions.cs rename to src/MagicOnion.Client.SourceGenerator/GeneratorOptions.cs diff --git a/src/MagicOnion.GeneratorCore/Internal/FNV1A32.cs b/src/MagicOnion.Client.SourceGenerator/Internal/FNV1A32.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/Internal/FNV1A32.cs rename to src/MagicOnion.Client.SourceGenerator/Internal/FNV1A32.cs diff --git a/src/MagicOnion.GeneratorCore/Internal/IMagicOnionGeneratorLogger.cs b/src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs similarity index 83% rename from src/MagicOnion.GeneratorCore/Internal/IMagicOnionGeneratorLogger.cs rename to src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs index c21c076cc..dc73047b2 100644 --- a/src/MagicOnion.GeneratorCore/Internal/IMagicOnionGeneratorLogger.cs +++ b/src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs @@ -4,7 +4,7 @@ public interface IMagicOnionGeneratorLogger { void Trace(string message); void Information(string message); - void Error(string message, Exception exception = null); + void Error(string message, Exception? exception = null); } public class MagicOnionGeneratorNullLogger : IMagicOnionGeneratorLogger @@ -19,7 +19,7 @@ public void Information(string message) { } - public void Error(string message, Exception exception = null) + public void Error(string message, Exception? exception = null) { } } @@ -46,7 +46,7 @@ public void Information(string message) Console.WriteLine(message); } - public void Error(string message, Exception exception = null) + public void Error(string message, Exception? exception = null) { Console.Error.WriteLine(message); } diff --git a/src/MagicOnion.GeneratorCore/Internal/IndentedTextWriterExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/Internal/IndentedTextWriterExtensions.cs rename to src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index 91fe0bb12..bfb4ab2fd 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -4,7 +4,7 @@ netstandard2.0 latest - enable + enable enable Nullable @@ -16,11 +16,43 @@ - + + + - + + + + + + EnumTemplate.tt + True + True + + + RegisterTemplate.tt + True + True + + + + + + MagicOnion.Generator.CodeGen + EnumTemplate.cs + TextTemplatingFilePreprocessor + + + MagicOnion.Generator.CodeGen + RegisterTemplate.cs + TextTemplatingFilePreprocessor + + + + + diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index e58544253..e2ec0d3d3 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -9,46 +9,6 @@ namespace MagicOnion.Client.SourceGenerator; -#if LEGACY_SOURCE_GENERATOR -[Generator(LanguageNames.CSharp)] -public class MagicOnionClientSourceGeneratorRoslyn3 : ISourceGenerator -{ - public void Initialize(GeneratorInitializationContext context) - { - context.RegisterForSyntaxNotifications(() => new SyntaxContextReceiver()); - } - - public void Execute(GeneratorExecutionContext context) - { - var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxContextReceiver!; - var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); - if (ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) - { - var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); - var outputs = compiler.Generate(syntaxReceiver.Candidates.ToImmutableArray(), referenceSymbols, options, context.CancellationToken); - foreach (var output in outputs) - { - context.AddSource(output.Path, output.Source); - } - } - } -} - -class SyntaxContextReceiver : ISyntaxContextReceiver -{ - public List Candidates { get; } = new(); - - public void OnVisitSyntaxNode(GeneratorSyntaxContext context) - { - if (SyntaxHelper.IsCandidateInterface(context.Node)) - { - Candidates.Add((INamedTypeSymbol)context.SemanticModel.GetDeclaredSymbol(context.Node)!); - } - } -} - - -#else [Generator(LanguageNames.CSharp)] public class MagicOnionClientSourceGenerator : IIncrementalGenerator { @@ -72,9 +32,11 @@ public void Initialize(IncrementalGeneratorInitializationContext context) .Combine(context.CompilationProvider) .WithTrackingName("mo_Source"); - context.RegisterSourceOutput(source, static (sourceProductionContext, pair) => + context.RegisterSourceOutput(source, static (sourceProductionContext, values) => { - var (((options, interfaces), referenceSymbols), compilation) = pair; + var (((options, interfaces), referenceSymbols), compilation) = values; + if (referenceSymbols is null) return; + var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); var symbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); var generated = compiler.Generate(symbols, referenceSymbols, options, sourceProductionContext.CancellationToken); @@ -85,7 +47,6 @@ public void Initialize(IncrementalGeneratorInitializationContext context) }); } } -#endif static class SyntaxHelper { diff --git a/src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/MagicOnionCompiler.cs rename to src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs diff --git a/src/MagicOnion.GeneratorCore/Utils/RoslynExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs similarity index 79% rename from src/MagicOnion.GeneratorCore/Utils/RoslynExtensions.cs rename to src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs index df1686a66..025ca859d 100644 --- a/src/MagicOnion.GeneratorCore/Utils/RoslynExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs @@ -37,36 +37,34 @@ public static IEnumerable EnumerateBaseType(this ITypeSymbol s } } - public static AttributeData FindAttribute(this IEnumerable attributeDataList, string typeName) + public static AttributeData? FindAttribute(this IEnumerable attributeDataList, string typeName) { - return attributeDataList - .Where(x => x.AttributeClass.ToDisplayString() == typeName) - .FirstOrDefault(); + return attributeDataList.FirstOrDefault(x => x.AttributeClass?.ToDisplayString() == typeName); } - public static AttributeData FindAttributeShortName(this IEnumerable attributeDataList, + public static AttributeData? FindAttributeShortName(this IEnumerable attributeDataList, string typeName) { - return attributeDataList - .Where(x => x.AttributeClass.Name == typeName) - .FirstOrDefault(); + return attributeDataList.FirstOrDefault(x => x.AttributeClass?.Name == typeName); } - public static AttributeData FindAttributeIncludeBasePropertyShortName(this IPropertySymbol property, - string typeName) + public static AttributeData? FindAttributeIncludeBasePropertyShortName(this IPropertySymbol property, string typeName) { - do + while (true) { var data = FindAttributeShortName(property.GetAttributes(), typeName); if (data != null) return data; + if (property.OverriddenProperty is null) + { + break; + } property = property.OverriddenProperty; - } while (property != null); + } return null; } - public static AttributeSyntax FindAttribute(this BaseTypeDeclarationSyntax typeDeclaration, SemanticModel model, - string typeName) + public static AttributeSyntax? FindAttribute(this BaseTypeDeclarationSyntax typeDeclaration, SemanticModel model, string typeName) { return typeDeclaration.AttributeLists .SelectMany(x => x.Attributes) @@ -74,14 +72,14 @@ public static AttributeSyntax FindAttribute(this BaseTypeDeclarationSyntax typeD .FirstOrDefault(); } - public static INamedTypeSymbol FindBaseTargetType(this ITypeSymbol symbol, string typeName) + public static INamedTypeSymbol? FindBaseTargetType(this ITypeSymbol symbol, string typeName) { return symbol.EnumerateBaseType() .Where(x => x.OriginalDefinition?.ToDisplayString() == typeName) .FirstOrDefault(); } - public static object GetSingleNamedArgumentValue(this AttributeData attribute, string key) + public static object? GetSingleNamedArgumentValue(this AttributeData attribute, string key) { foreach (var item in attribute.NamedArguments) { diff --git a/src/MagicOnion.GeneratorCore/Utils/TypeExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Utils/TypeExtensions.cs similarity index 100% rename from src/MagicOnion.GeneratorCore/Utils/TypeExtensions.cs rename to src/MagicOnion.Client.SourceGenerator/Utils/TypeExtensions.cs diff --git a/src/MagicOnion.GeneratorCore/CodeAnalysis/ReferenceSymbols.cs b/src/MagicOnion.GeneratorCore/CodeAnalysis/ReferenceSymbols.cs deleted file mode 100644 index bc0e13948..000000000 --- a/src/MagicOnion.GeneratorCore/CodeAnalysis/ReferenceSymbols.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.CodeAnalysis; - -namespace MagicOnion.Generator.CodeAnalysis; - -public record ReferenceSymbols -{ - public INamedTypeSymbol IServiceMarker { get; init; } - public INamedTypeSymbol IService { get; init; } - public INamedTypeSymbol IStreamingHubMarker { get; init; } - public INamedTypeSymbol IStreamingHub { get; init; } - - public static bool TryCreate(Compilation compilation, out ReferenceSymbols referenceSymbols) - { - if (compilation.GetTypeByMetadataName("MagicOnion.IServiceMarker") is { } symbolIServiceMarker && - compilation.GetTypeByMetadataName("MagicOnion.IService`1") is { } symbolIService && - compilation.GetTypeByMetadataName("MagicOnion.IStreamingHubMarker") is { } symbolIStreamingHubMarker && - compilation.GetTypeByMetadataName("MagicOnion.IStreamingHub`2") is { } symbolIStreamingHub - ) - { - referenceSymbols = new ReferenceSymbols() - { - IService = symbolIService, - IServiceMarker = symbolIServiceMarker, - IStreamingHub = symbolIStreamingHub, - IStreamingHubMarker = symbolIStreamingHubMarker, - }; - return true; - } - - referenceSymbols = default; - return false; - } -} diff --git a/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj b/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj index e3723329c..ecdf3e575 100644 --- a/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj +++ b/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj @@ -16,33 +16,9 @@ - - - MagicOnion.Generator.CodeGen - EnumTemplate.cs - TextTemplatingFilePreprocessor - - - MagicOnion.Generator.CodeGen - RegisterTemplate.cs - TextTemplatingFilePreprocessor - - - - - True - True - EnumTemplate.tt - - - True - True - RegisterTemplate.tt - - diff --git a/src/MagicOnion.GeneratorCore/Utils/PseudoCompilation.cs b/src/MagicOnion.GeneratorCore/Utils/PseudoCompilation.cs deleted file mode 100644 index 94edfbc5b..000000000 --- a/src/MagicOnion.GeneratorCore/Utils/PseudoCompilation.cs +++ /dev/null @@ -1,510 +0,0 @@ -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Xml; -using System.Xml.Linq; -using MagicOnion.Generator.Internal; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.Extensions.FileSystemGlobbing; - -namespace MagicOnion.Generator.Utils; - -internal static class PseudoCompilation -{ - public static Task CreateFromProjectAsync(string[] csprojs, string[] preprocessorSymbols, IMagicOnionGeneratorLogger logger, CancellationToken cancellationToken) - { - var parseOption = new CSharpParseOptions(LanguageVersion.Latest, DocumentationMode.Parse, SourceCodeKind.Regular, CleanPreprocessorSymbols(preprocessorSymbols)); - var syntaxTrees = new List(); - - logger.Trace($"[{nameof(PseudoCompilation)}] Creating compilation from project(s). (PreprocessorSymbolNames={string.Join(";", parseOption.PreprocessorSymbolNames)})"); - - var sources = new HashSet(); - var locations = new List(); - var globalUsings = new HashSet<(string Namespace, bool Static)>(); - foreach (var csproj in csprojs) - { - CollectDocument(csproj, sources, locations, globalUsings, logger); - } - - foreach (var file in sources.Select(Path.GetFullPath).Distinct()) - { - var path = NormalizeDirectorySeparators(file); - logger.Trace($"[{nameof(PseudoCompilation)}] Source '{path}'"); - var text = File.ReadAllText(NormalizeDirectorySeparators(file), Encoding.UTF8); - var syntax = CSharpSyntaxTree.ParseText(text, parseOption, path); - syntaxTrees.Add(syntax); - } - syntaxTrees.Add(CSharpSyntaxTree.ParseText(string.Join(Environment.NewLine, globalUsings.Select(x => $"global using {(x.Static ? "static" : "")} {x.Namespace};")))); - - // ignore Unity's default metadatas(to avoid conflict .NET Core runtime import) - // MonoBleedingEdge = .NET 4.x Unity metadata - // 2.0.0 = .NET Standard 2.0 Unity metadata - var metadata = new Dictionary(StringComparer.OrdinalIgnoreCase); - var targetMetadataLocations = locations.Select(Path.GetFullPath) - .Concat(GetStandardReferences()) - .Distinct() - .Where(x => !(x.Contains("MonoBleedingEdge") || x.Contains("2.0.0"))) - // .NET (Core) SDK libraries are prioritized. - .OrderBy(x => x.Contains(".NETCore") ? 0 : 1) - // We expect the NuGet package path to contain the version. :) - .ThenByDescending(x => x); - - var netCoreBundledAssemblies = new[] - { - "Microsoft.Bcl.AsyncInterfaces.dll", - "System.Buffers.dll", - "System.Memory.dll", - "System.Runtime.CompilerServices.Unsafe.dll", - "System.Threading.Tasks.Extensions.dll", - }; - - var hasNetCoreLibrariesLoaded = false; - foreach (var item in targetMetadataLocations) - { - if (File.Exists(item)) - { - var assemblyFileName = Path.GetFileName(item); - if (metadata.ContainsKey(assemblyFileName)) - { - logger.Trace($"[{nameof(PseudoCompilation)}] Loading Metadata '{item}' (Skipped. Different version of the library is already loaded.)"); - } - else if (hasNetCoreLibrariesLoaded && netCoreBundledAssemblies.Contains(assemblyFileName, StringComparer.OrdinalIgnoreCase)) - { - logger.Trace($"[{nameof(PseudoCompilation)}] Loading Metadata '{item}' (Skipped. Use .NET Runtime assembly instead.)"); - } - else - { - logger.Trace($"[{nameof(PseudoCompilation)}] Loading Metadata '{item}'."); - metadata.Add(assemblyFileName, MetadataReference.CreateFromFile(item)); - - if (item.Contains("Microsoft.NETCore.App")) - { - hasNetCoreLibrariesLoaded = true; - } - } - } - else - { - logger.Trace($"[{nameof(PseudoCompilation)}] Loading Metadata '{item}'. But it could not be found."); - } - } - - - var compilation = CSharpCompilation.Create( - "CodeGenTemp", - syntaxTrees, - metadata.Values, - new CSharpCompilationOptions( - OutputKind.DynamicallyLinkedLibrary, - allowUnsafe: true, - metadataImportOptions: MetadataImportOptions.All)); - - var diagnostics = compilation.GetDiagnostics(cancellationToken); - if (diagnostics.Any()) - { - foreach (var diagnostic in diagnostics.Where(x => x.Severity == DiagnosticSeverity.Error)) - { - logger.Trace($"[{nameof(PseudoCompilation)}] CompilationDiagnostic: {diagnostic.ToString()}"); - } - } - - return Task.FromResult(compilation); - } - - public static async Task CreateFromDirectoryAsync(string directoryRoot, string[] preprocessorSymbols, string dummyAnnotation, CancellationToken cancellationToken) - { - var parseOption = new CSharpParseOptions(LanguageVersion.Latest, DocumentationMode.Parse, SourceCodeKind.Regular, CleanPreprocessorSymbols(preprocessorSymbols)); - - var syntaxTrees = new List(); - foreach (var file in IterateCsFileWithoutBinObj(directoryRoot)) - { - var text = File.ReadAllText(NormalizeDirectorySeparators(file), Encoding.UTF8); - var syntax = CSharpSyntaxTree.ParseText(text, parseOption); - syntaxTrees.Add(syntax); - if (Path.GetFileNameWithoutExtension(file) == "Attributes") - { - var root = await syntax.GetRootAsync(cancellationToken).ConfigureAwait(false); - } - } - - syntaxTrees.Add(CSharpSyntaxTree.ParseText(dummyAnnotation, parseOption)); - - var metadata = GetStandardReferences().Select(x => MetadataReference.CreateFromFile(x)).ToArray(); - - var compilation = CSharpCompilation.Create( - "CodeGenTemp", - syntaxTrees, - metadata, - new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true)); - - return compilation; - } - - private static List GetStandardReferences() - { - var standardMetadataType = new[] - { - typeof(object), - typeof(Attribute), - typeof(Enumerable), - typeof(Task<>), - typeof(IgnoreDataMemberAttribute), - typeof(System.Collections.Hashtable), - typeof(System.Collections.Generic.List<>), - typeof(System.Collections.Generic.HashSet<>), - typeof(System.Collections.Immutable.IImmutableList<>), - typeof(System.Linq.ILookup<,>), - typeof(System.Tuple<>), - typeof(System.ValueTuple<>), - typeof(System.Collections.Concurrent.ConcurrentDictionary<,>), - typeof(System.Collections.ObjectModel.ObservableCollection<>), - typeof(System.Net.Http.HttpClient), - }; - - var metadata = standardMetadataType - .Select(x => x.Assembly.Location) - .Distinct() - .ToList(); - - var dir = new FileInfo(typeof(object).Assembly.Location).Directory; - { - var path = Path.Combine(dir.FullName, "netstandard.dll"); - if (File.Exists(path)) - { - metadata.Add(path); - } - } - - { - var path = Path.Combine(dir.FullName, "System.Runtime.dll"); - if (File.Exists(path)) - { - metadata.Add(path); - } - } - - return metadata; - } - - private static IEnumerable CleanPreprocessorSymbols(string[] preprocessorSymbols) - { - if (preprocessorSymbols == null) - { - return null; - } - - return preprocessorSymbols.Where(x => !string.IsNullOrWhiteSpace(x)); - } - - private static void CollectDocument(string csproj, HashSet source, List metadataLocations, HashSet<(string Namespace, bool Static)> globalUsings, IMagicOnionGeneratorLogger logger) - { - logger.Trace($"[{nameof(PseudoCompilation)}] Open project '{csproj}'"); - - XDocument document; - using (var sr = new StreamReader(csproj, true)) - { - var reader = new XmlTextReader(sr); - reader.Namespaces = false; - - document = XDocument.Load(reader, LoadOptions.None); - } - - var csProjRoot = Path.GetDirectoryName(csproj); - // .NET Core root - var framworkRoot = Path.GetDirectoryName(typeof(object).Assembly.Location); - - // Legacy - // - // New - // - var proj = document.Element("Project"); - var legacyFormat = !(proj.Attribute("Sdk")?.Value?.StartsWith("Microsoft.NET.Sdk") ?? false); - - if (!legacyFormat) - { - // try to find EnableDefaultCompileItems - if (document.Descendants("EnableDefaultCompileItems")?.FirstOrDefault()?.Value == "false" - || document.Descendants("EnableDefaultItems")?.FirstOrDefault()?.Value == "false") - { - legacyFormat = true; - } - } - - { - // compile files - { - // default include - if (!legacyFormat) - { - foreach (var path in GetCompileFullPaths(null, "**/*.cs", csProjRoot)) - { - source.Add(path); - } - } - - // custom elements - foreach (var item in document.Descendants("Compile")) - { - var include = item.Attribute("Include")?.Value; - if (include != null) - { - foreach (var path in GetCompileFullPaths(item, include, csProjRoot)) - { - source.Add(path); - } - } - - var remove = item.Attribute("Remove")?.Value; - if (remove != null) - { - foreach (var path in GetCompileFullPaths(item, remove, csProjRoot)) - { - source.Remove(path); - } - } - } - - // default remove - if (!legacyFormat) - { - foreach (var path in GetCompileFullPaths(null, "./bin/**;./obj/**", csProjRoot)) - { - source.Remove(path); - } - } - } - - // ImplicitUsings / Using - if (document.Descendants("ImplicitUsings").FirstOrDefault()?.Value?.ToLowerInvariant() is "enable" or "true") - { - globalUsings.Add(("global::System", false)); - globalUsings.Add(("global::System.Collections.Generic", false)); - globalUsings.Add(("global::System.IO", false)); - globalUsings.Add(("global::System.Linq", false)); - globalUsings.Add(("global::System.Net.Http", false)); - globalUsings.Add(("global::System.Threading", false)); - globalUsings.Add(("global::System.Threading.Tasks", false)); - } - foreach (var item in document.Descendants("Using")) - { - if (item.Attribute("Include")?.Value is { } includeUsing) - { - globalUsings.Add((includeUsing, string.Equals(item.Attribute("Static")?.Value, "True", StringComparison.OrdinalIgnoreCase))); - } - else if (item.Attribute("Remove")?.Value is { } removeUsing) - { - globalUsings.Remove((removeUsing, string.Equals(item.Attribute("Static")?.Value, "True", StringComparison.OrdinalIgnoreCase))); - } - } - - // shared - foreach (var item in document.Descendants("Import")) - { - if (item.Attribute("Label")?.Value == "Shared") - { - var sharedRoot = Path.GetDirectoryName(Path.Combine(csProjRoot, item.Attribute("Project").Value)); - logger.Trace($"[{nameof(PseudoCompilation)}] Import project '{sharedRoot}'"); - foreach (var file in IterateCsFileWithoutBinObj(sharedRoot)) - { - source.Add(file); - } - } - } - - // proj-ref - foreach (var item in document.Descendants("ProjectReference")) - { - var refCsProjPath = item.Attribute("Include")?.Value; - if (refCsProjPath != null) - { - logger.Trace($"[{nameof(PseudoCompilation)}] Resolve ProjectReference '{refCsProjPath}'"); - CollectDocument(Path.Combine(csProjRoot, NormalizeDirectorySeparators(refCsProjPath)), source, metadataLocations, globalUsings, logger); - } - } - - // metadata - foreach (var item in document.Descendants("Reference")) - { - var hintPath = item.Element("HintPath")?.Value; - if (hintPath == null) - { - var path = Path.Combine(framworkRoot, item.Attribute("Include").Value + ".dll"); - logger.Trace($"[{nameof(PseudoCompilation)}] Assembly Reference '{path}'"); - metadataLocations.Add(path); - } - else - { - var path = Path.Combine(csProjRoot, NormalizeDirectorySeparators(hintPath)); - logger.Trace($"[{nameof(PseudoCompilation)}] Assembly Reference '{path}' (from HintPath)"); - metadataLocations.Add(path); - } - } - - // resolve NuGet reference - var nugetPackagesPath = Environment.GetEnvironmentVariable("NUGET_PACKAGES"); - if (nugetPackagesPath == null) - { - // Try default - // Windows: %userprofile%\.nuget\packages - // Mac/Linux: ~/.nuget/packages - nugetPackagesPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "packages"); - } - - var resolvedDllPaths = new HashSet(); - void CollectNugetPackages(string id, string packageVersion, string originalTargetFramework) - { - logger.Trace($"[{nameof(PseudoCompilation)}] NuGet Package '{id} {packageVersion}'"); - var packageAssemblyResolved = false; - foreach (var targetFramework in NetstandardFallBack(originalTargetFramework).Distinct()) - { - var pathpath = Path.Combine(nugetPackagesPath, id, packageVersion, "lib", targetFramework); - if (!Directory.Exists(pathpath)) - { - pathpath = pathpath.ToLower(); // try all lower. - } - - if (Directory.Exists(pathpath)) - { - if (resolvedDllPaths.Add(pathpath)) - { - logger.Trace($"[{nameof(PseudoCompilation)}] Resolved assembly '{pathpath}' (targetFramework={targetFramework})"); - foreach (var dependency in ResolveNuGetDependency(nugetPackagesPath, id, packageVersion, targetFramework)) - { - CollectNugetPackages(dependency.id, dependency.version, originalTargetFramework); - } - } - - packageAssemblyResolved = true; - break; - } - } - - if (!packageAssemblyResolved) - { - logger.Trace($"[{nameof(PseudoCompilation)}] Could not find package assembly for '{id} {packageVersion}'"); - } - } - - foreach (var item in document.Descendants("PackageReference")) - { - var originalTargetFramework = document.Descendants("TargetFramework").FirstOrDefault()?.Value ?? document.Descendants("TargetFrameworks").First().Value.Split(';').First(); - var includePath = item.Attribute("Include")?.Value.Trim().ToLower(); // maybe lower - if (includePath == null) continue; - - var packageVersion = item.Attribute("Version").Value.Trim(); - - CollectNugetPackages(includePath, packageVersion, originalTargetFramework); - } - - foreach (var item in resolvedDllPaths) - { - foreach (var dllPath in Directory.GetFiles(item, "*.dll")) - { - metadataLocations.Add(Path.GetFullPath(dllPath)); - } - } - } - } - - private static IEnumerable NetstandardFallBack(string originalTargetFramework) - { - yield return originalTargetFramework; - if (originalTargetFramework.Contains("netcoreapp")) - { - yield return "netcoreapp3.1"; - yield return "netcoreapp3.0"; - yield return "netcoreapp2.1"; - yield return "netcoreapp2.0"; - } - - yield return "netstandard2.1"; - yield return "netstandard2.0"; - yield return "netstandard1.6"; - } - - private static IEnumerable<(string id, string version)> ResolveNuGetDependency(string nugetPackagesPath, string includePath, string packageVersion, string targetFramework) - { - var dirPath = Path.Combine(nugetPackagesPath, includePath, packageVersion); - if (!Directory.Exists(dirPath)) - { - dirPath = dirPath.ToLower(); // try all lower. - } - - var filePath = Path.Combine(dirPath, includePath.ToLower() + ".nuspec"); - if (File.Exists(filePath)) - { - XDocument document; - using (var sr = new StreamReader(filePath, true)) - { - var reader = new XmlTextReader(sr); - reader.Namespaces = false; - - document = XDocument.Load(reader, LoadOptions.None); - } - - foreach (var item in document.Descendants().Where(x => x.Name == "dependencies")) - { - foreach (var tf in NetstandardFallBack(targetFramework)) - { - foreach (var item2 in item.Elements().Where(x => x.Name == "group" && x.Attributes().Any(a => a.Name == "targetFramework" && (a.Value?.Trim('.')?.Equals(tf, StringComparison.OrdinalIgnoreCase) ?? false)))) - { - foreach (var item3 in item2.Descendants().Where(x => x.Name == "dependency")) - { - yield return (item3.Attribute("id").Value, item3.Attribute("version").Value); - } - - // found, stop search. - yield break; - } - } - } - } - } - - private static IEnumerable IterateCsFileWithoutBinObj(string root) - { - foreach (var item in Directory.EnumerateFiles(root, "*.cs", SearchOption.TopDirectoryOnly)) - { - yield return item; - } - - foreach (var dir in Directory.GetDirectories(root, "*", SearchOption.TopDirectoryOnly)) - { - var dirName = new DirectoryInfo(dir).Name; - if (dirName == "bin" || dirName == "obj") - { - continue; - } - - foreach (var item in IterateCsFileWithoutBinObj(dir)) - { - yield return item; - } - } - } - - private static string NormalizeDirectorySeparators(string path) - { - return path.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar); - } - - private static IEnumerable GetCompileFullPaths(XElement compile, string includeOrRemovePattern, string csProjRoot) - { - // solve macro - includeOrRemovePattern = includeOrRemovePattern.Replace("$(ProjectDir)", csProjRoot); - - var matcher = new Matcher(StringComparison.OrdinalIgnoreCase); - matcher.AddIncludePatterns(includeOrRemovePattern.Split(';')); - var exclude = compile?.Attribute("Exclude")?.Value; - if (exclude != null) - { - matcher.AddExcludePatterns(exclude.Split(';')); - } - - foreach (var path in matcher.GetResultsInFullPath(csProjRoot)) - { - yield return path; - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj index f7fa28c4d..03da1d1af 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj @@ -25,6 +25,7 @@ + From 23496a7d62c69bbdc325ad30e52b6e282929da7d Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 10 Oct 2023 18:46:59 +0900 Subject: [PATCH 11/66] Remove Generator, Generator.Core and Add SourceGenerator.Unity --- MagicOnion.sln | 26 ++----- ...cOnion.Client.SourceGenerator.Unity.csproj | 15 ++-- .../MagicOnionClientSourceGenerator.cs | 72 ++++--------------- .../Internal/SyntaxHelper.cs | 11 +++ .../MagicOnionClientSourceGenerator.cs | 10 +-- .../Collector/MagicOnionTypeInfoTest.cs | 1 + 6 files changed, 43 insertions(+), 92 deletions(-) create mode 100644 src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs diff --git a/MagicOnion.sln b/MagicOnion.sln index a41a96ea0..77c323f9e 100644 --- a/MagicOnion.sln +++ b/MagicOnion.sln @@ -27,8 +27,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{15598FE3-2 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Abstractions", "src\MagicOnion.Abstractions\MagicOnion.Abstractions.csproj", "{2AD48C05-ED44-4E4F-B86B-A746E7F968A9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.GeneratorCore", "src\MagicOnion.GeneratorCore\MagicOnion.GeneratorCore.csproj", "{EE768243-100A-4075-8823-C49EA086680A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{42EBB7E4-52D7-4E57-80AD-79FDD4900E13}" ProjectSection(SolutionItems) = preProject Directory.Build.props = Directory.Build.props @@ -46,8 +44,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtAuthApp.Server", "sample EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtAuthApp.Client", "samples\JwtAuthentication\JwtAuthApp.Client\JwtAuthApp.Client.csproj", "{5948D82F-EA56-4266-8718-7508C26BFFD4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Generator.Tests", "tests\MagicOnion.Generator.Tests\MagicOnion.Generator.Tests.csproj", "{E5415D78-63D2-4573-BA53-E923506A9C30}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Server", "src\MagicOnion.Server\MagicOnion.Server.csproj", "{72D2C01C-765C-4FE1-89CA-28244DEC7C37}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sandbox.AspNetCore", "sandbox\Sandbox.AspNetCore\Sandbox.AspNetCore.csproj", "{E70D0B00-0524-4EBE-B290-64DDB6B323F9}" @@ -106,7 +102,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGenerator.Tests", "tests\MagicOnion.Client.SourceGenerator.Tests\MagicOnion.Client.SourceGenerator.Tests.csproj", "{632C8D1B-3293-4D02-9ED1-0CB191619334}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Generator", "src\MagicOnion.Generator\MagicOnion.Generator.csproj", "{1BE960DA-4F54-4128-AEAE-993960DB9455}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicOnion.Client.SourceGenerator.Unity", "src\MagicOnion.Client.SourceGenerator.Unity\MagicOnion.Client.SourceGenerator.Unity.csproj", "{A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -126,10 +122,6 @@ Global {2AD48C05-ED44-4E4F-B86B-A746E7F968A9}.Debug|Any CPU.Build.0 = Debug|Any CPU {2AD48C05-ED44-4E4F-B86B-A746E7F968A9}.Release|Any CPU.ActiveCfg = Release|Any CPU {2AD48C05-ED44-4E4F-B86B-A746E7F968A9}.Release|Any CPU.Build.0 = Release|Any CPU - {EE768243-100A-4075-8823-C49EA086680A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EE768243-100A-4075-8823-C49EA086680A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EE768243-100A-4075-8823-C49EA086680A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EE768243-100A-4075-8823-C49EA086680A}.Release|Any CPU.Build.0 = Release|Any CPU {5CDEE44D-8AC2-4E7C-90CC-669E336F2D15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5CDEE44D-8AC2-4E7C-90CC-669E336F2D15}.Debug|Any CPU.Build.0 = Debug|Any CPU {5CDEE44D-8AC2-4E7C-90CC-669E336F2D15}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -146,10 +138,6 @@ Global {5948D82F-EA56-4266-8718-7508C26BFFD4}.Debug|Any CPU.Build.0 = Debug|Any CPU {5948D82F-EA56-4266-8718-7508C26BFFD4}.Release|Any CPU.ActiveCfg = Release|Any CPU {5948D82F-EA56-4266-8718-7508C26BFFD4}.Release|Any CPU.Build.0 = Release|Any CPU - {E5415D78-63D2-4573-BA53-E923506A9C30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E5415D78-63D2-4573-BA53-E923506A9C30}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E5415D78-63D2-4573-BA53-E923506A9C30}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E5415D78-63D2-4573-BA53-E923506A9C30}.Release|Any CPU.Build.0 = Release|Any CPU {72D2C01C-765C-4FE1-89CA-28244DEC7C37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {72D2C01C-765C-4FE1-89CA-28244DEC7C37}.Debug|Any CPU.Build.0 = Debug|Any CPU {72D2C01C-765C-4FE1-89CA-28244DEC7C37}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -238,10 +226,10 @@ Global {632C8D1B-3293-4D02-9ED1-0CB191619334}.Debug|Any CPU.Build.0 = Debug|Any CPU {632C8D1B-3293-4D02-9ED1-0CB191619334}.Release|Any CPU.ActiveCfg = Release|Any CPU {632C8D1B-3293-4D02-9ED1-0CB191619334}.Release|Any CPU.Build.0 = Release|Any CPU - {1BE960DA-4F54-4128-AEAE-993960DB9455}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1BE960DA-4F54-4128-AEAE-993960DB9455}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1BE960DA-4F54-4128-AEAE-993960DB9455}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1BE960DA-4F54-4128-AEAE-993960DB9455}.Release|Any CPU.Build.0 = Release|Any CPU + {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -250,14 +238,12 @@ Global {C79CE0BF-ED4C-47BE-822E-E82CF83FC68A} = {1987061F-8970-4018-8D58-6932961C9EB4} {7B7CFF27-CB38-4661-9CFC-473B4E38F0DE} = {FEE2B9AB-A1D0-41BA-A172-FC95935542DF} {2AD48C05-ED44-4E4F-B86B-A746E7F968A9} = {1987061F-8970-4018-8D58-6932961C9EB4} - {EE768243-100A-4075-8823-C49EA086680A} = {1987061F-8970-4018-8D58-6932961C9EB4} {5CDEE44D-8AC2-4E7C-90CC-669E336F2D15} = {FEE2B9AB-A1D0-41BA-A172-FC95935542DF} {FEE2B9AB-A1D0-41BA-A172-FC95935542DF} = {5A3F5158-7B17-4586-9885-9E60C1393185} {EBF51D3A-A093-4177-865A-D17F816EDEF5} = {5A3F5158-7B17-4586-9885-9E60C1393185} {93BC9FC7-D157-4541-A05E-C56D31B2F2BC} = {EBF51D3A-A093-4177-865A-D17F816EDEF5} {38B41013-6FD3-4E99-A7A9-0DBAC0CAF6F5} = {EBF51D3A-A093-4177-865A-D17F816EDEF5} {5948D82F-EA56-4266-8718-7508C26BFFD4} = {EBF51D3A-A093-4177-865A-D17F816EDEF5} - {E5415D78-63D2-4573-BA53-E923506A9C30} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} {72D2C01C-765C-4FE1-89CA-28244DEC7C37} = {1987061F-8970-4018-8D58-6932961C9EB4} {E70D0B00-0524-4EBE-B290-64DDB6B323F9} = {7682EFFC-681C-4DCC-B5E7-D8449E42DAC9} {4DE802A2-426D-4074-B9F3-710980B3EDA8} = {1987061F-8970-4018-8D58-6932961C9EB4} @@ -283,7 +269,7 @@ Global {95C3B040-BD5A-4A80-B5D4-26CAA21B4829} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} {7130EC5B-C987-487A-B319-E91B6D03F5BF} = {1987061F-8970-4018-8D58-6932961C9EB4} {632C8D1B-3293-4D02-9ED1-0CB191619334} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} - {1BE960DA-4F54-4128-AEAE-993960DB9455} = {1987061F-8970-4018-8D58-6932961C9EB4} + {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD} = {1987061F-8970-4018-8D58-6932961C9EB4} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D5B2E7E3-B727-40A1-BE68-7BAC9B9DE2FE} diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj index 3799bdf19..9716a33ac 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -4,7 +4,7 @@ netstandard2.0 latest - enable + enable enable Nullable @@ -15,11 +15,18 @@ - - + + + + + + - + + + + diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs index e58544253..77bbd5515 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs @@ -1,16 +1,13 @@ -using System.Collections.Generic; using System.Collections.Immutable; -using System.Linq; +using MagicOnion.Client.SourceGenerator.Internal; using MagicOnion.Generator; using MagicOnion.Generator.CodeAnalysis; using MagicOnion.Generator.Internal; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace MagicOnion.Client.SourceGenerator; +namespace MagicOnion.Client.SourceGenerator.Unity; -#if LEGACY_SOURCE_GENERATOR -[Generator(LanguageNames.CSharp)] +[Generator] public class MagicOnionClientSourceGeneratorRoslyn3 : ISourceGenerator { public void Initialize(GeneratorInitializationContext context) @@ -20,12 +17,15 @@ public void Initialize(GeneratorInitializationContext context) public void Execute(GeneratorExecutionContext context) { - var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxContextReceiver!; + var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxReceiver!; var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); if (ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) { var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); - var outputs = compiler.Generate(syntaxReceiver.Candidates.ToImmutableArray(), referenceSymbols, options, context.CancellationToken); + var interfaceSymbols = syntaxReceiver.Candidates + .Select(x => (INamedTypeSymbol)context.Compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!) + .ToImmutableArray(); + var outputs = compiler.Generate(interfaceSymbols, referenceSymbols, options, context.CancellationToken); foreach (var output in outputs) { context.AddSource(output.Path, output.Source); @@ -34,61 +34,15 @@ public void Execute(GeneratorExecutionContext context) } } -class SyntaxContextReceiver : ISyntaxContextReceiver +class SyntaxContextReceiver : ISyntaxReceiver { - public List Candidates { get; } = new(); + public List Candidates { get; } = new(); - public void OnVisitSyntaxNode(GeneratorSyntaxContext context) + public void OnVisitSyntaxNode(SyntaxNode syntaxNode) { - if (SyntaxHelper.IsCandidateInterface(context.Node)) + if (SyntaxHelper.IsCandidateInterface(syntaxNode)) { - Candidates.Add((INamedTypeSymbol)context.SemanticModel.GetDeclaredSymbol(context.Node)!); + Candidates.Add(syntaxNode); } } } - - -#else -[Generator(LanguageNames.CSharp)] -public class MagicOnionClientSourceGenerator : IIncrementalGenerator -{ - public void Initialize(IncrementalGeneratorInitializationContext context) - { - var options = context.AdditionalTextsProvider.Collect() - .Select(static (x, cancellationToken) => GeneratorOptions.Create(x, cancellationToken)) - .WithTrackingName("mo_GeneratorOptions"); - var referenceSymbols = context.CompilationProvider - .Select(static (x, cancellationToken) => ReferenceSymbols.TryCreate(x, out var rs) ? rs : default) - .WithTrackingName("mo_ReferenceSymbols"); - var interfaces = context.SyntaxProvider.CreateSyntaxProvider( - predicate: (node, ct) => SyntaxHelper.IsCandidateInterface(node), - transform: (ctx, ct) => ctx.Node) - .Collect() - .WithTrackingName("mo_Interfaces"); - - var source = options - .Combine(interfaces) - .Combine(referenceSymbols) - .Combine(context.CompilationProvider) - .WithTrackingName("mo_Source"); - - context.RegisterSourceOutput(source, static (sourceProductionContext, pair) => - { - var (((options, interfaces), referenceSymbols), compilation) = pair; - var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); - var symbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); - var generated = compiler.Generate(symbols, referenceSymbols, options, sourceProductionContext.CancellationToken); - foreach (var (path, source) in generated) - { - sourceProductionContext.AddSource(path, source); - } - }); - } -} -#endif - -static class SyntaxHelper -{ - public static bool IsCandidateInterface(SyntaxNode node) - => node is InterfaceDeclarationSyntax interfaceDeclaration && (interfaceDeclaration.BaseList?.Types.Any() ?? false); -} diff --git a/src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs b/src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs new file mode 100644 index 000000000..e72a77939 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs @@ -0,0 +1,11 @@ +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis; + +namespace MagicOnion.Client.SourceGenerator.Internal; + +internal static class SyntaxHelper +{ + public static bool IsCandidateInterface(SyntaxNode node) + => node is InterfaceDeclarationSyntax interfaceDeclaration && (interfaceDeclaration.BaseList?.Types.Any() ?? false); +} + diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index e2ec0d3d3..8f7f7a911 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -1,11 +1,9 @@ -using System.Collections.Generic; using System.Collections.Immutable; -using System.Linq; +using MagicOnion.Client.SourceGenerator.Internal; using MagicOnion.Generator; using MagicOnion.Generator.CodeAnalysis; using MagicOnion.Generator.Internal; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; namespace MagicOnion.Client.SourceGenerator; @@ -47,9 +45,3 @@ public void Initialize(IncrementalGeneratorInitializationContext context) }); } } - -static class SyntaxHelper -{ - public static bool IsCandidateInterface(SyntaxNode node) - => node is InterfaceDeclarationSyntax interfaceDeclaration && (interfaceDeclaration.BaseList?.Types.Any() ?? false); -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs index 0b4f2d190..cbab1f7f6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs @@ -170,6 +170,7 @@ public void CreateFromType_Enum_Array() typeInfo.IsEnum.Should().BeFalse(); typeInfo.UnderlyingType.Should().BeNull(); typeInfo.IsArray.Should().BeTrue(); + Assert.NotNull(typeInfo.ElementType); typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.CreateEnum("System", "DayOfWeek", MagicOnionTypeInfo.CreateValueType("System", "Int32"))); typeInfo.ElementType.IsEnum.Should().BeTrue(); typeInfo.ElementType.IsArray.Should().BeFalse(); From 60253c29a2f7893d59502cbc5d2ee9f960bdc6e1 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 10 Oct 2023 18:57:21 +0900 Subject: [PATCH 12/66] Adjust namespace --- .../MagicOnionClientSourceGenerator.cs | 4 +--- .../IMagicOnionCompileDirectiveTarget.cs | 2 +- .../CodeAnalysis/IMagicOnionServiceInfo.cs | 2 +- .../CodeAnalysis/MagicOnionMethodParameterInfo.cs | 2 +- .../CodeAnalysis/MagicOnionServiceCollection.cs | 2 +- .../CodeAnalysis/MagicOnionServiceInfo.cs | 2 +- .../CodeAnalysis/MagicOnionStreamingHubInfo.cs | 2 +- .../CodeAnalysis/MagicOnionTypeInfo.cs | 4 ++-- .../CodeAnalysis/MethodCollector.cs | 6 +++--- .../CodeAnalysis/MethodType.cs | 2 +- .../CodeAnalysis/ReferenceSymbols.cs | 2 +- .../CodeAnalysis/SerializationFormatterNameMapper.cs | 2 +- .../CodeAnalysis/SerializationInfo.cs | 2 +- .../CodeAnalysis/SerializationInfoCollector.cs | 5 ++--- .../CodeGen/EnumTemplate.cs | 4 ++-- .../CodeGen/EnumTemplate.tt | 2 +- .../Extensions/MagicOnionHubMethodInfoExtensions.cs | 4 ++-- .../MagicOnionMethodParameterInfoExtensions.cs | 4 ++-- .../Extensions/MagicOnionServiceInfoExtensions.cs | 4 ++-- .../CodeGen/ISerializerFormatterGenerator.cs | 2 +- .../MemoryPackFormatterRegistrationGenerator.cs | 9 ++------- .../CodeGen/MessagePackFormatterResolverGenerator.cs | 11 +++-------- .../CodeGen/RegisterTemplate.cs | 4 ++-- .../CodeGen/RegisterTemplate.tt | 2 +- .../CodeGen/SerializationFormatterCodeGenContext.cs | 4 ++-- .../CodeGen/StaticMagicOnionClientGenerator.cs | 8 ++++---- .../CodeGen/StaticStreamingHubClientGenerator.cs | 8 ++++---- .../CodeGen/TemplatePartials.cs | 4 ++-- .../GeneratorOptions.cs | 3 +-- .../Internal/FNV1A32.cs | 2 +- .../Internal/IMagicOnionGeneratorLogger.cs | 2 +- .../Internal/IndentedTextWriterExtensions.cs | 2 +- .../MagicOnion.Client.SourceGenerator.csproj | 4 ++-- .../MagicOnionClientSourceGenerator.cs | 4 +--- .../MagicOnionCompiler.cs | 12 ++++++------ .../Utils/RoslynExtensions.cs | 2 +- .../Utils/TypeExtensions.cs | 3 +-- .../Collector/MagicOnionTypeInfoTest.cs | 2 +- .../Collector/SerializationInfoCollectorTest.cs | 2 +- .../GeneratorOptionsTest.cs | 1 - .../MagicOnionGeneratorTestOutputLogger.cs | 2 +- .../Verifiers/MagicOnionSourceGeneratorVerifier.cs | 1 - 42 files changed, 66 insertions(+), 85 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs index 77bbd5515..3a762bc69 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs @@ -1,8 +1,6 @@ using System.Collections.Immutable; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; using MagicOnion.Client.SourceGenerator.Internal; -using MagicOnion.Generator; -using MagicOnion.Generator.CodeAnalysis; -using MagicOnion.Generator.Internal; using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator.Unity; diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs index 4a30f0c4b..10a869011 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs @@ -1,4 +1,4 @@ -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; public interface IMagicOnionCompileDirectiveTarget { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionServiceInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionServiceInfo.cs index 04c2e74f4..06efd04bb 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionServiceInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionServiceInfo.cs @@ -1,4 +1,4 @@ -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; public interface IMagicOnionServiceInfo : IMagicOnionCompileDirectiveTarget { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs index c56bbcfb6..7cc06a9b6 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using Microsoft.CodeAnalysis; -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; [DebuggerDisplay("Parameter: {Name,nq} ({Type,nq})")] public class MagicOnionMethodParameterInfo diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceCollection.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceCollection.cs index 664afb5ca..7f8b0ab98 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceCollection.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceCollection.cs @@ -1,4 +1,4 @@ -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; public class MagicOnionServiceCollection { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceInfo.cs index 60fe76466..e0cac2d4d 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceInfo.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; [DebuggerDisplay("MagicOnionService: {ServiceType,nq}; Methods={Methods.Count,nq}")] public class MagicOnionServiceInfo : IMagicOnionServiceInfo diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionStreamingHubInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionStreamingHubInfo.cs index ee569e265..c90c850fb 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionStreamingHubInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionStreamingHubInfo.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; [DebuggerDisplay("StreamingHub: {ServiceType,nq}; Methods={Methods.Count,nq}")] public class MagicOnionStreamingHubInfo : IMagicOnionServiceInfo diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs index 9ccc6ae05..cb7f7cf08 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs @@ -1,8 +1,8 @@ using System.Diagnostics; -using MagicOnion.Generator.Utils; +using MagicOnion.Client.SourceGenerator.Utils; using Microsoft.CodeAnalysis; -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; [DebuggerDisplay("{ToDisplayName(DisplayNameFormat.Short),nq}")] public class MagicOnionTypeInfo : IEquatable diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index 93458b2e8..ed0db23f0 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -1,9 +1,9 @@ using System.Collections.Immutable; -using MagicOnion.Generator.Internal; -using MagicOnion.Generator.Utils; +using MagicOnion.Client.SourceGenerator.Internal; +using MagicOnion.Client.SourceGenerator.Utils; using Microsoft.CodeAnalysis; -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; /// /// Provides logic to collect MagicOnion Services and StreamingHubs from a compilation. diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodType.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodType.cs index b4efa1b25..1fc5602a5 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodType.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodType.cs @@ -1,4 +1,4 @@ -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; public enum MethodType { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/ReferenceSymbols.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/ReferenceSymbols.cs index 8977ddbd9..d592c89ba 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/ReferenceSymbols.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/ReferenceSymbols.cs @@ -1,7 +1,7 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; public record ReferenceSymbols(INamedTypeSymbol IServiceMarker, INamedTypeSymbol IService, INamedTypeSymbol IStreamingHubMarker, INamedTypeSymbol IStreamingHub) { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs index 6a8cecab6..458e2d638 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; public interface ISerializationFormatterNameMapper { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfo.cs index 23abd5653..93833967b 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfo.cs @@ -1,4 +1,4 @@ -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; // MessagePack Definitions public interface ISerializationFormatterRegisterInfo diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs index 6d2994ba1..5702d5a5a 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs @@ -1,8 +1,7 @@ using System.Diagnostics; -using MagicOnion.Generator.Internal; -using static MagicOnion.Generator.CodeAnalysis.SerializationInfoCollector; +using MagicOnion.Client.SourceGenerator.Internal; -namespace MagicOnion.Generator.CodeAnalysis; +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; /// /// Provides logic for gathering information to determine required formatters (for enums, collections and user-defined generic types). diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs index 76feec8a1..1fb6b6db2 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs @@ -7,12 +7,12 @@ // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MagicOnion.Generator.CodeGen +namespace MagicOnion.Client.SourceGenerator.CodeGen { using System.Linq; using System.Text; using System.Collections.Generic; - using MagicOnion.Generator.CodeGen.Extensions; + using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; using System; /// diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt b/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt index a7191396b..4fa10bc03 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt @@ -3,7 +3,7 @@ <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> -<#@ import namespace="MagicOnion.Generator.CodeGen.Extensions" #> +<#@ import namespace="MagicOnion.Client.SourceGenerator.CodeGen.Extensions" #> #pragma warning disable 618 #pragma warning disable 612 #pragma warning disable 414 diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionHubMethodInfoExtensions.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionHubMethodInfoExtensions.cs index cb3cb79c5..0e8b1080b 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionHubMethodInfoExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionHubMethodInfoExtensions.cs @@ -1,6 +1,6 @@ -using MagicOnion.Generator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; -namespace MagicOnion.Generator.CodeGen.Extensions; +namespace MagicOnion.Client.SourceGenerator.CodeGen.Extensions; public static class MagicOnionHubMethodInfoExtensions { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionMethodParameterInfoExtensions.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionMethodParameterInfoExtensions.cs index b827266b6..a7d572c7b 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionMethodParameterInfoExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionMethodParameterInfoExtensions.cs @@ -1,6 +1,6 @@ -using MagicOnion.Generator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; -namespace MagicOnion.Generator.CodeGen.Extensions; +namespace MagicOnion.Client.SourceGenerator.CodeGen.Extensions; public static class MagicOnionMethodParameterInfoExtensions { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs index bbb5f41ca..88dfa1bb8 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs @@ -1,7 +1,7 @@ -using MagicOnion.Generator.CodeAnalysis; using System.Text.RegularExpressions; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; -namespace MagicOnion.Generator.CodeGen.Extensions; +namespace MagicOnion.Client.SourceGenerator.CodeGen.Extensions; public static class MagicOnionServiceInfoExtensions { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/ISerializerFormatterGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/ISerializerFormatterGenerator.cs index 296b3bfff..5fe986e18 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/ISerializerFormatterGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/ISerializerFormatterGenerator.cs @@ -1,4 +1,4 @@ -namespace MagicOnion.Generator.CodeGen; +namespace MagicOnion.Client.SourceGenerator.CodeGen; public interface ISerializerFormatterGenerator { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs index c310a419d..a70d3b31e 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs @@ -1,11 +1,6 @@ -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.Text; -using MagicOnion.Generator.CodeAnalysis; -using MagicOnion.Generator.Internal; +using MagicOnion.Client.SourceGenerator.Internal; -namespace MagicOnion.Generator.CodeGen; +namespace MagicOnion.Client.SourceGenerator.CodeGen; internal class MemoryPackFormatterRegistrationGenerator : ISerializerFormatterGenerator { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs index 79b16707e..33c50c781 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs @@ -1,11 +1,6 @@ -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.Text; -using MagicOnion.Generator.CodeAnalysis; -using MagicOnion.Generator.Internal; - -namespace MagicOnion.Generator.CodeGen; +using MagicOnion.Client.SourceGenerator.Internal; + +namespace MagicOnion.Client.SourceGenerator.CodeGen; internal class MessagePackFormatterResolverGenerator : ISerializerFormatterGenerator { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs index 3c852a35f..0fc239fa3 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs @@ -7,12 +7,12 @@ // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MagicOnion.Generator.CodeGen +namespace MagicOnion.Client.SourceGenerator.CodeGen { using System.Linq; using System.Text; using System.Collections.Generic; - using MagicOnion.Generator.CodeGen.Extensions; + using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; using System; /// diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt index c78048ccc..a260a1001 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt @@ -3,7 +3,7 @@ <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> -<#@ import namespace="MagicOnion.Generator.CodeGen.Extensions" #> +<#@ import namespace="MagicOnion.Client.SourceGenerator.CodeGen.Extensions" #> #pragma warning disable 618 #pragma warning disable 612 #pragma warning disable 414 diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs index 4424855a9..76f3431e4 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs @@ -1,7 +1,7 @@ using System.CodeDom.Compiler; -using MagicOnion.Generator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; -namespace MagicOnion.Generator.CodeGen; +namespace MagicOnion.Client.SourceGenerator.CodeGen; public class SerializationFormatterCodeGenContext { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs index ea9e883c1..81088bd9e 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs @@ -1,9 +1,9 @@ using System.CodeDom.Compiler; -using MagicOnion.Generator.CodeAnalysis; -using MagicOnion.Generator.CodeGen.Extensions; -using MagicOnion.Generator.Internal; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; +using MagicOnion.Client.SourceGenerator.Internal; -namespace MagicOnion.Generator.CodeGen; +namespace MagicOnion.Client.SourceGenerator.CodeGen; public class StaticMagicOnionClientGenerator { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs index 44555e9b5..6f3ad6b8b 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs @@ -1,9 +1,9 @@ -using MagicOnion.Generator.CodeAnalysis; -using MagicOnion.Generator.CodeGen.Extensions; -using MagicOnion.Generator.Internal; using System.CodeDom.Compiler; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; +using MagicOnion.Client.SourceGenerator.Internal; -namespace MagicOnion.Generator.CodeGen; +namespace MagicOnion.Client.SourceGenerator.CodeGen; public class StaticStreamingHubClientGenerator { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs index cc28b1d87..0211e990a 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs @@ -1,6 +1,6 @@ -using MagicOnion.Generator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; -namespace MagicOnion.Generator.CodeGen; +namespace MagicOnion.Client.SourceGenerator.CodeGen; public partial class RegisterTemplate { diff --git a/src/MagicOnion.Client.SourceGenerator/GeneratorOptions.cs b/src/MagicOnion.Client.SourceGenerator/GeneratorOptions.cs index bbd1b2858..bc5a193bb 100644 --- a/src/MagicOnion.Client.SourceGenerator/GeneratorOptions.cs +++ b/src/MagicOnion.Client.SourceGenerator/GeneratorOptions.cs @@ -1,9 +1,8 @@ using System.Collections.Immutable; using System.Text.Json; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; -namespace MagicOnion.Generator; +namespace MagicOnion.Client.SourceGenerator; /* [Option("u", "Do not use UnityEngine's RuntimeInitializeOnLoadMethodAttribute on MagicOnionInitializer. (Same as --disable-auto-register)")]bool noUseUnityAttr = false, diff --git a/src/MagicOnion.Client.SourceGenerator/Internal/FNV1A32.cs b/src/MagicOnion.Client.SourceGenerator/Internal/FNV1A32.cs index 8ef0640cd..e467c6251 100644 --- a/src/MagicOnion.Client.SourceGenerator/Internal/FNV1A32.cs +++ b/src/MagicOnion.Client.SourceGenerator/Internal/FNV1A32.cs @@ -1,6 +1,6 @@ using System.Text; -namespace MagicOnion.Generator.Internal; +namespace MagicOnion.Client.SourceGenerator.Internal; internal static class FNV1A32 { diff --git a/src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs b/src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs index dc73047b2..019abc02a 100644 --- a/src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs +++ b/src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs @@ -1,4 +1,4 @@ -namespace MagicOnion.Generator.Internal; +namespace MagicOnion.Client.SourceGenerator.Internal; public interface IMagicOnionGeneratorLogger { diff --git a/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs index 4fec32ebb..ef7d9911d 100644 --- a/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs @@ -1,6 +1,6 @@ using System.CodeDom.Compiler; -namespace MagicOnion.Generator.Internal; +namespace MagicOnion.Client.SourceGenerator.Internal; internal static class IndentedTextWriterExtensions { diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index bfb4ab2fd..f49b88bed 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -40,12 +40,12 @@ - MagicOnion.Generator.CodeGen + MagicOnion.Client.SourceGenerator.CodeGen EnumTemplate.cs TextTemplatingFilePreprocessor - MagicOnion.Generator.CodeGen + MagicOnion.Client.SourceGenerator.CodeGen RegisterTemplate.cs TextTemplatingFilePreprocessor diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 8f7f7a911..83498af93 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -1,8 +1,6 @@ using System.Collections.Immutable; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; using MagicOnion.Client.SourceGenerator.Internal; -using MagicOnion.Generator; -using MagicOnion.Generator.CodeAnalysis; -using MagicOnion.Generator.Internal; using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator; diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs index c345deb19..560a2308f 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs @@ -1,17 +1,17 @@ #pragma warning disable CS1998 using System.Collections.Immutable; -using System.Text; using System.Diagnostics; using System.Reflection; using System.Runtime.InteropServices; -using MagicOnion.Generator.CodeAnalysis; -using MagicOnion.Generator.CodeGen; -using MagicOnion.Generator.CodeGen.Extensions; -using MagicOnion.Generator.Internal; +using System.Text; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeGen; +using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; +using MagicOnion.Client.SourceGenerator.Internal; using Microsoft.CodeAnalysis; -namespace MagicOnion.Generator; +namespace MagicOnion.Client.SourceGenerator; public class MagicOnionCompiler { diff --git a/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs index 025ca859d..582dc3b34 100644 --- a/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs @@ -2,7 +2,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace MagicOnion.Generator.Utils; +namespace MagicOnion.Client.SourceGenerator.Utils; // Utility and Extension methods for Roslyn internal static class RoslynExtensions diff --git a/src/MagicOnion.Client.SourceGenerator/Utils/TypeExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Utils/TypeExtensions.cs index c9ed651f8..4dc59a07f 100644 --- a/src/MagicOnion.Client.SourceGenerator/Utils/TypeExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/Utils/TypeExtensions.cs @@ -1,7 +1,6 @@ -using System.Text; using Microsoft.CodeAnalysis; -namespace MagicOnion.Generator.Utils; +namespace MagicOnion.Client.SourceGenerator.Utils; internal static class TypeExtensions { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs index cbab1f7f6..22bac7293 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/MagicOnionTypeInfoTest.cs @@ -1,4 +1,4 @@ -using MagicOnion.Generator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator.Tests.Collector; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs index a84dc606b..bf98fb81b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs @@ -1,4 +1,4 @@ -using MagicOnion.Generator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; using Xunit.Abstractions; namespace MagicOnion.Client.SourceGenerator.Tests.Collector; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs index 6b640464d..61a82a2ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs @@ -1,5 +1,4 @@ using MagicOnion.Client.SourceGenerator.Tests.Verifiers; -using MagicOnion.Generator; namespace MagicOnion.Client.SourceGenerator.Tests; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs index 1ba6fd4e4..ed7a12c5e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs @@ -1,4 +1,4 @@ -using MagicOnion.Generator.Internal; +using MagicOnion.Client.SourceGenerator.Internal; using Xunit.Abstractions; namespace MagicOnion.Client.SourceGenerator.Tests; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index 08a241aca..58a8062fb 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -7,7 +7,6 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using System.Text; -using MagicOnion.Generator; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; From 260567b337321b12eb1e64405d42c7aec8fa1d7e Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 10 Oct 2023 19:02:37 +0900 Subject: [PATCH 13/66] Fix package references --- .../MagicOnion.Client.SourceGenerator.Unity.csproj | 5 ++++- .../MagicOnion.Client.SourceGenerator.csproj | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj index 9716a33ac..52de61afa 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -24,7 +24,10 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index f49b88bed..7b33239b5 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -16,7 +16,10 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + From ee2c4a01383df12910225e799501d655196393b2 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 15:44:06 +0900 Subject: [PATCH 14/66] Generator-generated code for integration testing --- Directory.Build.props | 6 + MagicOnionClientGeneratorOptions.schema.json | 26 + ...cOnion.Client.SourceGenerator.Unity.csproj | 4 +- .../MagicOnion.Client.SourceGenerator.csproj | 13 +- .../MagicOnion.Client.SourceGenerator.targets | 15 + .../MagicOnionClientSourceGenerator.cs | 4 +- .../MagicOnion.Client.SourceGenerator.target | 5 + .../GenerateClient.cmd | 3 - .../MagicOnion.Integration.Tests.csproj | 13 + .../MagicOnionClientGeneratorOptions.json | 5 + .../_GeneratedClient.cs | 977 ------------------ 11 files changed, 85 insertions(+), 986 deletions(-) create mode 100644 MagicOnionClientGeneratorOptions.schema.json create mode 100644 src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets create mode 100644 src/MagicOnion.Client.SourceGenerator/build/MagicOnion.Client.SourceGenerator.target delete mode 100644 tests/MagicOnion.Integration.Tests/GenerateClient.cmd create mode 100644 tests/MagicOnion.Integration.Tests/MagicOnionClientGeneratorOptions.json delete mode 100644 tests/MagicOnion.Integration.Tests/_GeneratedClient.cs diff --git a/Directory.Build.props b/Directory.Build.props index 6346669a5..a1759a12e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -22,6 +22,12 @@ snupkg + + + + + + diff --git a/MagicOnionClientGeneratorOptions.schema.json b/MagicOnionClientGeneratorOptions.schema.json new file mode 100644 index 000000000..b483ca391 --- /dev/null +++ b/MagicOnionClientGeneratorOptions.schema.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema", + "type": "object", + "properties": { + "disableAutoRegister": { + "description": "Disable automatically calling MagicOnionInitializer during start-up. (Automatic registration requires .NET 5+ or Unity)", + "type": "boolean" + }, + "namespace": { + "description": "The namespace of clients to generate.", + "type": "string" + }, + "messagePackFormatterNamespace": { + "description": "the namespace of pre-generated MessagePackFormatters.", + "type": "string" + }, + "serializer": { + "description": "The serializer used for message serialization.", + "type": "string", + "enum": [ + "MessagePack", + "MemoryPack" + ] + } + } +} \ No newline at end of file diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj index 52de61afa..54ed75288 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -29,7 +29,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index 7b33239b5..c1634d5b9 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -20,14 +20,21 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + + + true + build\ + + + EnumTemplate.tt @@ -58,4 +65,6 @@ + + diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets new file mode 100644 index 000000000..f5dbb6db6 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 83498af93..bdf60141a 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -17,8 +17,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context) .Select(static (x, cancellationToken) => ReferenceSymbols.TryCreate(x, out var rs) ? rs : default) .WithTrackingName("mo_ReferenceSymbols"); var interfaces = context.SyntaxProvider.CreateSyntaxProvider( - predicate: (node, ct) => SyntaxHelper.IsCandidateInterface(node), - transform: (ctx, ct) => ctx.Node) + predicate: (node, ct) => SyntaxHelper.IsCandidateInterface(node), + transform: (ctx, ct) => ctx.Node) .Collect() .WithTrackingName("mo_Interfaces"); diff --git a/src/MagicOnion.Client.SourceGenerator/build/MagicOnion.Client.SourceGenerator.target b/src/MagicOnion.Client.SourceGenerator/build/MagicOnion.Client.SourceGenerator.target new file mode 100644 index 000000000..9708ab755 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/build/MagicOnion.Client.SourceGenerator.target @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/MagicOnion.Integration.Tests/GenerateClient.cmd b/tests/MagicOnion.Integration.Tests/GenerateClient.cmd deleted file mode 100644 index 24dd9fe9e..000000000 --- a/tests/MagicOnion.Integration.Tests/GenerateClient.cmd +++ /dev/null @@ -1,3 +0,0 @@ -setlocal -cd ..\..\src\MagicOnion.Generator -dotnet run --framework net7.0 -- --verbose --disable-auto-register --namespace MagicOnion.Integration.Tests.Generated -i ../../tests/MagicOnion.Integration.Tests/MagicOnion.Integration.Tests.csproj -o ../../tests/MagicOnion.Integration.Tests/_GeneratedClient.cs diff --git a/tests/MagicOnion.Integration.Tests/MagicOnion.Integration.Tests.csproj b/tests/MagicOnion.Integration.Tests/MagicOnion.Integration.Tests.csproj index 603b58c3a..30ab51c79 100644 --- a/tests/MagicOnion.Integration.Tests/MagicOnion.Integration.Tests.csproj +++ b/tests/MagicOnion.Integration.Tests/MagicOnion.Integration.Tests.csproj @@ -25,6 +25,18 @@ + + + + + + + + + + + + @@ -34,4 +46,5 @@ + diff --git a/tests/MagicOnion.Integration.Tests/MagicOnionClientGeneratorOptions.json b/tests/MagicOnion.Integration.Tests/MagicOnionClientGeneratorOptions.json new file mode 100644 index 000000000..d19e4c91f --- /dev/null +++ b/tests/MagicOnion.Integration.Tests/MagicOnionClientGeneratorOptions.json @@ -0,0 +1,5 @@ +{ + "$schema": "../../MagicOnionClientGeneratorOptions.schema.json", + "disableAutoRegister": true, + "namespace": "MagicOnion.Integration.Tests.Generated" +} diff --git a/tests/MagicOnion.Integration.Tests/_GeneratedClient.cs b/tests/MagicOnion.Integration.Tests/_GeneratedClient.cs deleted file mode 100644 index 88a58d416..000000000 --- a/tests/MagicOnion.Integration.Tests/_GeneratedClient.cs +++ /dev/null @@ -1,977 +0,0 @@ -// -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. - -namespace MagicOnion.Integration.Tests.Generated -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::MagicOnion.Integration.Tests.IClientFilterTestService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnion.Integration.Tests.ClientFilterTestServiceClient(x, y))); - } - if (typeof(T) == typeof(global::MagicOnion.Integration.Tests.IDynamicArgumentTupleService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnion.Integration.Tests.DynamicArgumentTupleServiceClient(x, y))); - } - if (typeof(T) == typeof(global::MagicOnion.Integration.Tests.ISerializerTestService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnion.Integration.Tests.SerializerTestServiceClient(x, y))); - } - if (typeof(T) == typeof(global::MagicOnion.Integration.Tests.IStreamingTestService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnion.Integration.Tests.StreamingTestServiceClient(x, y))); - } - if (typeof(T) == typeof(global::MagicOnion.Integration.Tests.IUnaryService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnion.Integration.Tests.UnaryServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::MagicOnion.Integration.Tests.IHandCraftedStreamingHubClientTestHub) && typeof(TReceiver) == typeof(global::MagicOnion.Integration.Tests.IHandCraftedStreamingHubClientTestHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnion.Integration.Tests.HandCraftedStreamingHubClientTestHubClient(a, b, c, d, e))); - } - if (typeof(TStreamingHub) == typeof(global::MagicOnion.Integration.Tests.ISerializerTestHub) && typeof(TReceiver) == typeof(global::MagicOnion.Integration.Tests.ISerializerTestHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnion.Integration.Tests.SerializerTestHubClient(a, b, c, d, e))); - } - if (typeof(TStreamingHub) == typeof(global::MagicOnion.Integration.Tests.IStreamingHubTestHub) && typeof(TReceiver) == typeof(global::MagicOnion.Integration.Tests.IStreamingHubTestHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnion.Integration.Tests.StreamingHubTestHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. -namespace MagicOnion.Integration.Tests.Generated.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(5) - { - {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, - {typeof(global::MagicOnion.DynamicArgumentTuple), 1 }, - {typeof(global::MagicOnion.DynamicArgumentTuple), 2 }, - {typeof(global::MagicOnion.DynamicArgumentTuple), 3 }, - {typeof(global::System.ValueTuple), 4 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32), default(global::System.Int32)); - case 1: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.Int32), default(global::System.Int32)); - case 2: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.Int32), default(global::System.String), default(global::System.Boolean)); - case 3: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.Int32), default(global::System.String)); - case 4: return new global::MessagePack.Formatters.ValueTupleFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Integration.Tests.Generated.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Integration.Tests.Generated.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - } - } -} -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. - -namespace MagicOnion.Integration.Tests -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class ClientFilterTestServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MagicOnion.Integration.Tests.IClientFilterTestService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.Int32> Unary1; - public global::MagicOnion.Client.Internal.RawMethodInvoker HeaderEcho; - public global::MagicOnion.Client.Internal.RawMethodInvoker AlwaysError; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.Unary1 = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.Int32>(global::Grpc.Core.MethodType.Unary, "IClientFilterTestService", "Unary1", serializerProvider); - this.HeaderEcho = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IClientFilterTestService", "HeaderEcho", serializerProvider); - this.AlwaysError = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IClientFilterTestService", "AlwaysError", serializerProvider); - } - } - - readonly ClientCore core; - - public ClientFilterTestServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private ClientFilterTestServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new ClientFilterTestServiceClient(options, core); - - public global::MagicOnion.UnaryResult Unary1(global::System.Int32 x, global::System.Int32 y) - => this.core.Unary1.InvokeUnary(this, "IClientFilterTestService/Unary1", new global::MagicOnion.DynamicArgumentTuple(x, y)); - public global::MagicOnion.UnaryResult HeaderEcho() - => this.core.HeaderEcho.InvokeUnary(this, "IClientFilterTestService/HeaderEcho", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult AlwaysError() - => this.core.AlwaysError.InvokeUnary(this, "IClientFilterTestService/AlwaysError", global::MessagePack.Nil.Default); - } -} - -namespace MagicOnion.Integration.Tests -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class DynamicArgumentTupleServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MagicOnion.Integration.Tests.IDynamicArgumentTupleService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.Int32> Unary1; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.Unary1 = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.Int32>(global::Grpc.Core.MethodType.Unary, "IDynamicArgumentTupleService", "Unary1", serializerProvider); - } - } - - readonly ClientCore core; - - public DynamicArgumentTupleServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private DynamicArgumentTupleServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new DynamicArgumentTupleServiceClient(options, core); - - public global::MagicOnion.UnaryResult Unary1(global::System.Int32 arg0, global::System.Int32 arg1, global::System.Int32 arg2, global::System.Int32 arg3, global::System.Int32 arg4, global::System.Int32 arg5, global::System.Int32 arg6, global::System.Int32 arg7, global::System.Int32 arg8, global::System.Int32 arg9, global::System.Int32 arg10, global::System.Int32 arg11, global::System.Int32 arg12, global::System.Int32 arg13, global::System.Int32 arg14) - => this.core.Unary1.InvokeUnary(this, "IDynamicArgumentTupleService/Unary1", new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14)); - } -} - -namespace MagicOnion.Integration.Tests -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class SerializerTestServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MagicOnion.Integration.Tests.ISerializerTestService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker UnaryReturnNil; - public global::MagicOnion.Client.Internal.RawMethodInvoker UnaryParameterless; - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.Int32> Unary1; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.UnaryReturnNil = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "ISerializerTestService", "UnaryReturnNil", serializerProvider); - this.UnaryParameterless = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "ISerializerTestService", "UnaryParameterless", serializerProvider); - this.Unary1 = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.Int32>(global::Grpc.Core.MethodType.Unary, "ISerializerTestService", "Unary1", serializerProvider); - } - } - - readonly ClientCore core; - - public SerializerTestServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private SerializerTestServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new SerializerTestServiceClient(options, core); - - public global::MagicOnion.UnaryResult UnaryReturnNil() - => this.core.UnaryReturnNil.InvokeUnary(this, "ISerializerTestService/UnaryReturnNil", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult UnaryParameterless() - => this.core.UnaryParameterless.InvokeUnary(this, "ISerializerTestService/UnaryParameterless", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult Unary1(global::System.Int32 arg0, global::System.Int32 arg1, global::System.Int32 arg2, global::System.Int32 arg3, global::System.Int32 arg4, global::System.Int32 arg5, global::System.Int32 arg6, global::System.Int32 arg7, global::System.Int32 arg8, global::System.Int32 arg9, global::System.Int32 arg10, global::System.Int32 arg11, global::System.Int32 arg12, global::System.Int32 arg13, global::System.Int32 arg14) - => this.core.Unary1.InvokeUnary(this, "ISerializerTestService/Unary1", new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14)); - } -} - -namespace MagicOnion.Integration.Tests -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class StreamingTestServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MagicOnion.Integration.Tests.IStreamingTestService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.Int32> ClientStreaming; - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.Int32> ServerStreaming; - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.Int32> DuplexStreaming; - public global::MagicOnion.Client.Internal.RawMethodInvoker ClientStreamingRefType; - public global::MagicOnion.Client.Internal.RawMethodInvoker ServerStreamingRefType; - public global::MagicOnion.Client.Internal.RawMethodInvoker DuplexStreamingRefType; - public global::MagicOnion.Client.Internal.RawMethodInvoker ClientStreamingRefTypeReturnsNull; - public global::MagicOnion.Client.Internal.RawMethodInvoker ServerStreamingRefTypeReturnsNull; - public global::MagicOnion.Client.Internal.RawMethodInvoker DuplexStreamingRefTypeReturnsNull; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.ClientStreaming = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.Int32>(global::Grpc.Core.MethodType.ClientStreaming, "IStreamingTestService", "ClientStreaming", serializerProvider); - this.ServerStreaming = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.Int32>(global::Grpc.Core.MethodType.ServerStreaming, "IStreamingTestService", "ServerStreaming", serializerProvider); - this.DuplexStreaming = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.Int32>(global::Grpc.Core.MethodType.DuplexStreaming, "IStreamingTestService", "DuplexStreaming", serializerProvider); - this.ClientStreamingRefType = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.ClientStreaming, "IStreamingTestService", "ClientStreamingRefType", serializerProvider); - this.ServerStreamingRefType = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.ServerStreaming, "IStreamingTestService", "ServerStreamingRefType", serializerProvider); - this.DuplexStreamingRefType = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.DuplexStreaming, "IStreamingTestService", "DuplexStreamingRefType", serializerProvider); - this.ClientStreamingRefTypeReturnsNull = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.ClientStreaming, "IStreamingTestService", "ClientStreamingRefTypeReturnsNull", serializerProvider); - this.ServerStreamingRefTypeReturnsNull = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.ServerStreaming, "IStreamingTestService", "ServerStreamingRefTypeReturnsNull", serializerProvider); - this.DuplexStreamingRefTypeReturnsNull = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.DuplexStreaming, "IStreamingTestService", "DuplexStreamingRefTypeReturnsNull", serializerProvider); - } - } - - readonly ClientCore core; - - public StreamingTestServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private StreamingTestServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new StreamingTestServiceClient(options, core); - - public global::System.Threading.Tasks.Task, global::System.Int32>> ClientStreaming() - => this.core.ClientStreaming.InvokeClientStreaming(this, "IStreamingTestService/ClientStreaming"); - public global::System.Threading.Tasks.Task> ServerStreaming(global::System.Int32 arg0, global::System.Int32 arg1) - => this.core.ServerStreaming.InvokeServerStreaming(this, "IStreamingTestService/ServerStreaming", new global::MagicOnion.DynamicArgumentTuple(arg0, arg1)); - public global::System.Threading.Tasks.Task, global::System.Int32>> DuplexStreaming() - => this.core.DuplexStreaming.InvokeDuplexStreaming(this, "IStreamingTestService/DuplexStreaming"); - public global::System.Threading.Tasks.Task> ClientStreamingRefType() - => this.core.ClientStreamingRefType.InvokeClientStreaming(this, "IStreamingTestService/ClientStreamingRefType"); - public global::System.Threading.Tasks.Task> ServerStreamingRefType(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - => this.core.ServerStreamingRefType.InvokeServerStreaming(this, "IStreamingTestService/ServerStreamingRefType", request); - public global::System.Threading.Tasks.Task> DuplexStreamingRefType() - => this.core.DuplexStreamingRefType.InvokeDuplexStreaming(this, "IStreamingTestService/DuplexStreamingRefType"); - public global::System.Threading.Tasks.Task> ClientStreamingRefTypeReturnsNull() - => this.core.ClientStreamingRefTypeReturnsNull.InvokeClientStreaming(this, "IStreamingTestService/ClientStreamingRefTypeReturnsNull"); - public global::System.Threading.Tasks.Task> ServerStreamingRefTypeReturnsNull(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - => this.core.ServerStreamingRefTypeReturnsNull.InvokeServerStreaming(this, "IStreamingTestService/ServerStreamingRefTypeReturnsNull", request); - public global::System.Threading.Tasks.Task> DuplexStreamingRefTypeReturnsNull() - => this.core.DuplexStreamingRefTypeReturnsNull.InvokeDuplexStreaming(this, "IStreamingTestService/DuplexStreamingRefTypeReturnsNull"); - } -} - -namespace MagicOnion.Integration.Tests -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class UnaryServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MagicOnion.Integration.Tests.IUnaryService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker NonGeneric; - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.Int32> ManyParametersReturnsValueType; - public global::MagicOnion.Client.Internal.RawMethodInvoker RefType; - public global::MagicOnion.Client.Internal.RawMethodInvoker RefTypeNull; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.NonGeneric = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IUnaryService", "NonGeneric", serializerProvider); - this.ManyParametersReturnsValueType = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.Int32>(global::Grpc.Core.MethodType.Unary, "IUnaryService", "ManyParametersReturnsValueType", serializerProvider); - this.RefType = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.Unary, "IUnaryService", "RefType", serializerProvider); - this.RefTypeNull = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.Unary, "IUnaryService", "RefTypeNull", serializerProvider); - } - } - - readonly ClientCore core; - - public UnaryServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private UnaryServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new UnaryServiceClient(options, core); - - public global::MagicOnion.UnaryResult NonGeneric(global::System.Int32 arg0) - => this.core.NonGeneric.InvokeUnaryNonGeneric(this, "IUnaryService/NonGeneric", arg0); - public global::MagicOnion.UnaryResult ManyParametersReturnsValueType(global::System.Int32 arg0, global::System.Int32 arg1, global::System.Int32 arg2, global::System.Int32 arg3, global::System.Int32 arg4, global::System.Int32 arg5, global::System.Int32 arg6, global::System.Int32 arg7, global::System.Int32 arg8, global::System.Int32 arg9, global::System.Int32 arg10, global::System.Int32 arg11, global::System.Int32 arg12, global::System.Int32 arg13, global::System.Int32 arg14) - => this.core.ManyParametersReturnsValueType.InvokeUnary(this, "IUnaryService/ManyParametersReturnsValueType", new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14)); - public global::MagicOnion.UnaryResult RefType(global::MagicOnion.Integration.Tests.MyUnaryRequest request) - => this.core.RefType.InvokeUnary(this, "IUnaryService/RefType", request); - public global::MagicOnion.UnaryResult RefTypeNull(global::MagicOnion.Integration.Tests.MyUnaryRequest request) - => this.core.RefTypeNull.InvokeUnary(this, "IUnaryService/RefTypeNull", request); - } -} - - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. - -namespace MagicOnion.Integration.Tests -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class HandCraftedStreamingHubClientTestHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::MagicOnion.Integration.Tests.IHandCraftedStreamingHubClientTestHub - { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public HandCraftedStreamingHubClientTestHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IHandCraftedStreamingHubClientTestHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task MethodReturnWithoutValue() - => base.WriteMessageWithResponseAsync(-925124953, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task MethodParameterless() - => base.WriteMessageWithResponseAsync(-545082062, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task MethodParameter_One(global::System.Int32 arg0) - => base.WriteMessageWithResponseAsync(85995236, arg0); - public global::System.Threading.Tasks.Task MethodParameter_Many(global::System.Int32 arg0, global::System.String arg1) - => base.WriteMessageWithResponseAsync, global::System.Int32>(1242061127, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1)); - public global::System.Threading.Tasks.Task Callback(global::System.Int32 arg0, global::System.String arg1) - => base.WriteMessageWithResponseAsync, global::System.Int32>(-2118022106, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1)); - - public global::MagicOnion.Integration.Tests.IHandCraftedStreamingHubClientTestHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::MagicOnion.Integration.Tests.IHandCraftedStreamingHubClientTestHub - { - readonly HandCraftedStreamingHubClientTestHubClient parent; - - public FireAndForgetClient(HandCraftedStreamingHubClientTestHubClient parent) - => this.parent = parent; - - public global::MagicOnion.Integration.Tests.IHandCraftedStreamingHubClientTestHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task MethodReturnWithoutValue() - => parent.WriteMessageFireAndForgetAsync(-925124953, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task MethodParameterless() - => parent.WriteMessageFireAndForgetAsync(-545082062, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task MethodParameter_One(global::System.Int32 arg0) - => parent.WriteMessageFireAndForgetAsync(85995236, arg0); - public global::System.Threading.Tasks.Task MethodParameter_Many(global::System.Int32 arg0, global::System.String arg1) - => parent.WriteMessageFireAndForgetAsync, global::System.Int32>(1242061127, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1)); - public global::System.Threading.Tasks.Task Callback(global::System.Int32 arg0, global::System.String arg1) - => parent.WriteMessageFireAndForgetAsync, global::System.Int32>(-2118022106, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1)); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) - { - case -1262822265: // Void OnMessage(global::System.Int32 arg0, global::System.String arg1) - { - var value = base.Deserialize>(data); - receiver.OnMessage(value.Item1, value.Item2); - } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -925124953: // Task MethodReturnWithoutValue() - base.SetResultForResponse(taskCompletionSource, data); - break; - case -545082062: // Task MethodParameterless() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 85995236: // Task MethodParameter_One(global::System.Int32 arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1242061127: // Task MethodParameter_Many(global::System.Int32 arg0, global::System.String arg1) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -2118022106: // Task Callback(global::System.Int32 arg0, global::System.String arg1) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - - } -} - -namespace MagicOnion.Integration.Tests -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class SerializerTestHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::MagicOnion.Integration.Tests.ISerializerTestHub - { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public SerializerTestHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "ISerializerTestHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task MethodReturnWithoutValue() - => base.WriteMessageWithResponseAsync(-925124953, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task MethodParameterless() - => base.WriteMessageWithResponseAsync(-545082062, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task MethodParameter_One(global::System.Int32 arg0) - => base.WriteMessageWithResponseAsync(85995236, arg0); - public global::System.Threading.Tasks.Task MethodParameter_Many(global::System.Int32 arg0, global::System.String arg1) - => base.WriteMessageWithResponseAsync, global::System.Int32>(1242061127, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1)); - public global::System.Threading.Tasks.Task Callback(global::System.Int32 arg0, global::System.String arg1) - => base.WriteMessageWithResponseAsync, global::System.Int32>(-2118022106, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1)); - - public global::MagicOnion.Integration.Tests.ISerializerTestHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::MagicOnion.Integration.Tests.ISerializerTestHub - { - readonly SerializerTestHubClient parent; - - public FireAndForgetClient(SerializerTestHubClient parent) - => this.parent = parent; - - public global::MagicOnion.Integration.Tests.ISerializerTestHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task MethodReturnWithoutValue() - => parent.WriteMessageFireAndForgetAsync(-925124953, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task MethodParameterless() - => parent.WriteMessageFireAndForgetAsync(-545082062, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task MethodParameter_One(global::System.Int32 arg0) - => parent.WriteMessageFireAndForgetAsync(85995236, arg0); - public global::System.Threading.Tasks.Task MethodParameter_Many(global::System.Int32 arg0, global::System.String arg1) - => parent.WriteMessageFireAndForgetAsync, global::System.Int32>(1242061127, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1)); - public global::System.Threading.Tasks.Task Callback(global::System.Int32 arg0, global::System.String arg1) - => parent.WriteMessageFireAndForgetAsync, global::System.Int32>(-2118022106, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1)); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) - { - case -1262822265: // Void OnMessage(global::System.Int32 arg0, global::System.String arg1) - { - var value = base.Deserialize>(data); - receiver.OnMessage(value.Item1, value.Item2); - } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -925124953: // Task MethodReturnWithoutValue() - base.SetResultForResponse(taskCompletionSource, data); - break; - case -545082062: // Task MethodParameterless() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 85995236: // Task MethodParameter_One(global::System.Int32 arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1242061127: // Task MethodParameter_Many(global::System.Int32 arg0, global::System.String arg1) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -2118022106: // Task Callback(global::System.Int32 arg0, global::System.String arg1) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - - } -} - -namespace MagicOnion.Integration.Tests -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class StreamingHubTestHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::MagicOnion.Integration.Tests.IStreamingHubTestHub - { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public StreamingHubTestHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IStreamingHubTestHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task NoReturn_Parameter_Zero() - => base.WriteMessageWithResponseAsync(-933634881, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task NoReturn_Parameter_One(global::System.Int32 arg0) - => base.WriteMessageWithResponseAsync(1561818363, arg0); - public global::System.Threading.Tasks.Task NoReturn_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-423495298, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); - public global::System.Threading.Tasks.Task Parameter_Zero() - => base.WriteMessageWithResponseAsync(1994667803, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task Parameter_One(global::System.Int32 arg0) - => base.WriteMessageWithResponseAsync(1979862359, arg0); - public global::System.Threading.Tasks.Task Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - => base.WriteMessageWithResponseAsync, global::System.Int32>(1287160778, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); - public global::System.Threading.Tasks.Task CallReceiver_Parameter_Zero() - => base.WriteMessageWithResponseAsync(-686867585, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task CallReceiver_Parameter_One(global::System.Int32 arg0) - => base.WriteMessageWithResponseAsync(-283979077, arg0); - public global::System.Threading.Tasks.Task CallReceiver_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-601288642, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); - public global::System.Threading.Tasks.Task Never() - => base.WriteMessageWithResponseAsync(-1291900119, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task Never_With_Return() - => base.WriteMessageWithResponseAsync(2074829953, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.ValueTask ValueTask_NoReturn_Parameter_Zero() - => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(-1145997568, global::MessagePack.Nil.Default)); - public global::System.Threading.Tasks.ValueTask ValueTask_NoReturn_Parameter_One(global::System.Int32 arg0) - => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(928334602, arg0)); - public global::System.Threading.Tasks.ValueTask ValueTask_NoReturn_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1965648219, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2))); - public global::System.Threading.Tasks.ValueTask ValueTask_Parameter_Zero() - => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(658969434, global::MessagePack.Nil.Default)); - public global::System.Threading.Tasks.ValueTask ValueTask_Parameter_One(global::System.Int32 arg0) - => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(-435674772, arg0)); - public global::System.Threading.Tasks.ValueTask ValueTask_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync, global::System.Int32>(-52442641, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2))); - public global::System.Threading.Tasks.ValueTask ValueTask_Never() - => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(-1647082094, global::MessagePack.Nil.Default)); - public global::System.Threading.Tasks.ValueTask ValueTask_Never_With_Return() - => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(-1197600090, global::MessagePack.Nil.Default)); - public global::System.Threading.Tasks.Task RefType(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - => base.WriteMessageWithResponseAsync(1032130514, request); - public global::System.Threading.Tasks.Task RefType_Null(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - => base.WriteMessageWithResponseAsync(1253352858, request); - public global::System.Threading.Tasks.Task CallReceiver_RefType(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - => base.WriteMessageWithResponseAsync(1503747814, request); - public global::System.Threading.Tasks.Task CallReceiver_RefType_Null() - => base.WriteMessageWithResponseAsync(-1093215042, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task CallReceiver_Delay(global::System.Int32 milliseconds) - => base.WriteMessageWithResponseAsync(1865731236, milliseconds); - public global::System.Threading.Tasks.Task ThrowReturnStatusException() - => base.WriteMessageWithResponseAsync(28149104, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task Throw() - => base.WriteMessageWithResponseAsync(540272591, global::MessagePack.Nil.Default); - - public global::MagicOnion.Integration.Tests.IStreamingHubTestHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::MagicOnion.Integration.Tests.IStreamingHubTestHub - { - readonly StreamingHubTestHubClient parent; - - public FireAndForgetClient(StreamingHubTestHubClient parent) - => this.parent = parent; - - public global::MagicOnion.Integration.Tests.IStreamingHubTestHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task NoReturn_Parameter_Zero() - => parent.WriteMessageFireAndForgetAsync(-933634881, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task NoReturn_Parameter_One(global::System.Int32 arg0) - => parent.WriteMessageFireAndForgetAsync(1561818363, arg0); - public global::System.Threading.Tasks.Task NoReturn_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-423495298, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); - public global::System.Threading.Tasks.Task Parameter_Zero() - => parent.WriteMessageFireAndForgetAsync(1994667803, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task Parameter_One(global::System.Int32 arg0) - => parent.WriteMessageFireAndForgetAsync(1979862359, arg0); - public global::System.Threading.Tasks.Task Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - => parent.WriteMessageFireAndForgetAsync, global::System.Int32>(1287160778, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); - public global::System.Threading.Tasks.Task CallReceiver_Parameter_Zero() - => parent.WriteMessageFireAndForgetAsync(-686867585, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task CallReceiver_Parameter_One(global::System.Int32 arg0) - => parent.WriteMessageFireAndForgetAsync(-283979077, arg0); - public global::System.Threading.Tasks.Task CallReceiver_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-601288642, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); - public global::System.Threading.Tasks.Task Never() - => parent.WriteMessageFireAndForgetAsync(-1291900119, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task Never_With_Return() - => parent.WriteMessageFireAndForgetAsync(2074829953, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.ValueTask ValueTask_NoReturn_Parameter_Zero() - => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(-1145997568, global::MessagePack.Nil.Default)); - public global::System.Threading.Tasks.ValueTask ValueTask_NoReturn_Parameter_One(global::System.Int32 arg0) - => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(928334602, arg0)); - public global::System.Threading.Tasks.ValueTask ValueTask_NoReturn_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1965648219, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2))); - public global::System.Threading.Tasks.ValueTask ValueTask_Parameter_Zero() - => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(658969434, global::MessagePack.Nil.Default)); - public global::System.Threading.Tasks.ValueTask ValueTask_Parameter_One(global::System.Int32 arg0) - => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(-435674772, arg0)); - public global::System.Threading.Tasks.ValueTask ValueTask_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync, global::System.Int32>(-52442641, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2))); - public global::System.Threading.Tasks.ValueTask ValueTask_Never() - => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(-1647082094, global::MessagePack.Nil.Default)); - public global::System.Threading.Tasks.ValueTask ValueTask_Never_With_Return() - => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(-1197600090, global::MessagePack.Nil.Default)); - public global::System.Threading.Tasks.Task RefType(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - => parent.WriteMessageFireAndForgetAsync(1032130514, request); - public global::System.Threading.Tasks.Task RefType_Null(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - => parent.WriteMessageFireAndForgetAsync(1253352858, request); - public global::System.Threading.Tasks.Task CallReceiver_RefType(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - => parent.WriteMessageFireAndForgetAsync(1503747814, request); - public global::System.Threading.Tasks.Task CallReceiver_RefType_Null() - => parent.WriteMessageFireAndForgetAsync(-1093215042, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task CallReceiver_Delay(global::System.Int32 milliseconds) - => parent.WriteMessageFireAndForgetAsync(1865731236, milliseconds); - public global::System.Threading.Tasks.Task ThrowReturnStatusException() - => parent.WriteMessageFireAndForgetAsync(28149104, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task Throw() - => parent.WriteMessageFireAndForgetAsync(540272591, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) - { - case 1445325235: // Void Receiver_Parameter_Zero() - { - var value = base.Deserialize(data); - receiver.Receiver_Parameter_Zero(); - } - break; - case 1150128799: // Void Receiver_Parameter_One(global::System.Int32 arg0) - { - var value = base.Deserialize(data); - receiver.Receiver_Parameter_One(value); - } - break; - case 283674770: // Void Receiver_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - { - var value = base.Deserialize>(data); - receiver.Receiver_Parameter_Many(value.Item1, value.Item2, value.Item3); - } - break; - case -1554122998: // Void Receiver_RefType(global::MagicOnion.Integration.Tests.MyStreamingResponse request) - { - var value = base.Deserialize(data); - receiver.Receiver_RefType(value); - } - break; - case -218411390: // Void Receiver_RefType_Null(global::MagicOnion.Integration.Tests.MyStreamingResponse request) - { - var value = base.Deserialize(data); - receiver.Receiver_RefType_Null(value); - } - break; - case -5486432: // Void Receiver_Delay() - { - var value = base.Deserialize(data); - receiver.Receiver_Delay(); - } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -933634881: // Task NoReturn_Parameter_Zero() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1561818363: // Task NoReturn_Parameter_One(global::System.Int32 arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -423495298: // Task NoReturn_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1994667803: // Task Parameter_Zero() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1979862359: // Task Parameter_One(global::System.Int32 arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1287160778: // Task Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -686867585: // Task CallReceiver_Parameter_Zero() - base.SetResultForResponse(taskCompletionSource, data); - break; - case -283979077: // Task CallReceiver_Parameter_One(global::System.Int32 arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -601288642: // Task CallReceiver_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -1291900119: // Task Never() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 2074829953: // Task Never_With_Return() - base.SetResultForResponse(taskCompletionSource, data); - break; - case -1145997568: // ValueTask ValueTask_NoReturn_Parameter_Zero() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 928334602: // ValueTask ValueTask_NoReturn_Parameter_One(global::System.Int32 arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -1965648219: // ValueTask ValueTask_NoReturn_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 658969434: // ValueTask ValueTask_Parameter_Zero() - base.SetResultForResponse(taskCompletionSource, data); - break; - case -435674772: // ValueTask ValueTask_Parameter_One(global::System.Int32 arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -52442641: // ValueTask ValueTask_Parameter_Many(global::System.Int32 arg0, global::System.String arg1, global::System.Boolean arg2) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -1647082094: // ValueTask ValueTask_Never() - base.SetResultForResponse(taskCompletionSource, data); - break; - case -1197600090: // ValueTask ValueTask_Never_With_Return() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1032130514: // Task RefType(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1253352858: // Task RefType_Null(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1503747814: // Task CallReceiver_RefType(global::MagicOnion.Integration.Tests.MyStreamingRequest request) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -1093215042: // Task CallReceiver_RefType_Null() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1865731236: // Task CallReceiver_Delay(global::System.Int32 milliseconds) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 28149104: // Task ThrowReturnStatusException() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 540272591: // Task Throw() - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - - } -} - - From fa0402589977de3d5993f7b34510d9723df2ccd9 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 15:58:52 +0900 Subject: [PATCH 15/66] Fix code generation test for MemoryPack --- .../GeneratorOptionsTest.cs | 6 +- ...cOnion.Client.SourceGenerator.Tests.csproj | 4 +- .../MagicOnion_MagicOnionInitializer.g.cs | 97 +++++++++++++++++++ ...MagicOnionMemoryPackFormatterProvider.g.cs | 30 ++++++ .../MyApplication1_GreeterServiceClient.g.cs | 54 +++++++++++ .../MagicOnionSourceGeneratorVerifier.cs | 22 ++++- 6 files changed, 208 insertions(+), 5 deletions(-) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs index 61a82a2ba..a6a4ed6a5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GeneratorOptionsTest.cs @@ -99,6 +99,10 @@ public interface IGreeterService : IService } """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source, options: GeneratorOptions.Default with { Serializer = GeneratorOptions.SerializerType.MemoryPack }); + await MagicOnionSourceGeneratorVerifier.RunAsync( + source, + options: GeneratorOptions.Default with { Serializer = GeneratorOptions.SerializerType.MemoryPack }, + verifierOptions: VerifierOptions.Default with { UseMemoryPack = true } + ); } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj index 03da1d1af..d66af386d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -12,6 +12,7 @@ + @@ -34,6 +35,7 @@ + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d013f540a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs @@ -0,0 +1,97 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MagicOnion +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + +#if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] +#endif + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + +} + +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs new file mode 100644 index 000000000..3147aa523 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs @@ -0,0 +1,30 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +namespace MagicOnion +{ + using global::System; + using global::MemoryPack; + public class MagicOnionMemoryPackFormatterProvider + { + public static void RegisterFormatters() + { + global::MemoryPack.MemoryPackFormatterProvider.Register(new global::MagicOnion.Serialization.MemoryPack.DynamicArgumentTupleFormatter()); + } + } +} +#pragma warning restore 168 +#pragma warning restore 219 +#pragma warning restore 414 +#pragma warning restore 612 +#pragma warning restore 618 + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs new file mode 100644 index 000000000..0e3ddaf1f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 219 +#pragma warning disable 168 + +// NOTE: Disable warnings for nullable reference types. +// `#nullable disable` causes compile error on old C# compilers (-7.3) +#pragma warning disable 8603 // Possible null reference return. +#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. +#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + +namespace MyApplication1 +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + [global::MagicOnion.Ignore] + public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + } +} + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index 58a8062fb..0677e4bd3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -17,18 +17,23 @@ namespace MagicOnion.Client.SourceGenerator.Tests.Verifiers; +internal record VerifierOptions(bool UseMemoryPack) +{ + public static VerifierOptions Default { get; } = new VerifierOptions(UseMemoryPack: false); +} + internal class MagicOnionSourceGeneratorVerifier { - public static async Task RunAsync(string testSourceCode, GeneratorOptions? options = null, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) + public static async Task RunAsync(string testSourceCode, GeneratorOptions? options = null, VerifierOptions? verifierOptions = null, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) { if (string.IsNullOrEmpty(testSourceCode)) throw new ArgumentNullException(nameof(testSourceCode)); if (string.IsNullOrEmpty(testFile)) throw new ArgumentNullException(nameof(testFile)); if (string.IsNullOrEmpty(testMethod)) throw new ArgumentNullException(nameof(testMethod)); - await RunAsync(new[] { ("Source.cs", testSourceCode) }, options, testFile, testMethod); + await RunAsync(new[] { ("Source.cs", testSourceCode) }, options, verifierOptions, testFile, testMethod); } - public static async Task RunAsync(IEnumerable<(string Path, string Content)> testSourceCodes, GeneratorOptions? options = null, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) + public static async Task RunAsync(IEnumerable<(string Path, string Content)> testSourceCodes, GeneratorOptions? options = null, VerifierOptions? verifierOptions = null, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) { if (testSourceCodes is null) throw new ArgumentNullException(nameof(testSourceCodes)); if (string.IsNullOrEmpty(testFile)) throw new ArgumentNullException(nameof(testFile)); @@ -46,6 +51,17 @@ public static async Task RunAsync(IEnumerable<(string Path, string Content)> tes test.TestState.AdditionalFiles.Add((GeneratorOptions.JsonFileName, options.ToJson())); } + if (verifierOptions is not null) + { + if (verifierOptions.UseMemoryPack) + { + // MemoryPack.Core + test.TestState.AdditionalReferences.Add(typeof(MemoryPack.IMemoryPackFormatter).Assembly); + // MagicOnion.Serialization.MemoryPack + test.TestState.AdditionalReferences.Add(typeof(MagicOnion.Serialization.MemoryPack.DynamicArgumentTupleFormatter).Assembly); + } + } + test.TestState.Sources.AddRange(testSourceCodes.Select(x => (x.Path, SourceText.From(x.Content, Encoding.UTF8, SourceHashAlgorithm.Sha1)))); await test.RunAsync(); } From fe43c711c2186b984b0532b7d892042d22a54e9d Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 16:09:11 +0900 Subject: [PATCH 16/66] Remove IMagicOnionGeneratorLogger --- .../MagicOnionClientSourceGenerator.cs | 2 +- .../CodeAnalysis/MethodCollector.cs | 29 +++------- .../SerializationInfoCollector.cs | 10 +--- .../Internal/IMagicOnionGeneratorLogger.cs | 53 ------------------- .../MagicOnionClientSourceGenerator.cs | 2 +- .../MagicOnionCompiler.cs | 35 +----------- .../SerializationInfoCollectorTest.cs | 30 +++++------ .../MagicOnionGeneratorTestOutputLogger.cs | 22 -------- 8 files changed, 27 insertions(+), 156 deletions(-) delete mode 100644 src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs index 3a762bc69..b17a24f56 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs @@ -19,7 +19,7 @@ public void Execute(GeneratorExecutionContext context) var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); if (ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) { - var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); + var compiler = new MagicOnionCompiler(); var interfaceSymbols = syntaxReceiver.Candidates .Select(x => (INamedTypeSymbol)context.Compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!) .ToImmutableArray(); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index ed0db23f0..396e0b151 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -10,18 +10,16 @@ namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; /// public class MethodCollector { - readonly IMagicOnionGeneratorLogger logger; readonly CancellationToken cancellationToken; - public MethodCollector(IMagicOnionGeneratorLogger? logger = null, CancellationToken cancellationToken = default) + public MethodCollector(CancellationToken cancellationToken = default) { - this.logger = logger ?? MagicOnionGeneratorNullLogger.Instance; this.cancellationToken = cancellationToken; } public MagicOnionServiceCollection Collect(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) { - var ctx = MethodCollectorContext.CreateFromInterfaceSymbols(interfaceSymbols, referenceSymbols, logger); + var ctx = MethodCollectorContext.CreateFromInterfaceSymbols(interfaceSymbols, referenceSymbols); return new MagicOnionServiceCollection(GetStreamingHubs(ctx), GetServices(ctx)); } @@ -36,10 +34,8 @@ IReadOnlyList GetStreamingHubs(MethodCollectorContex var hasIgnore = HasIgnoreAttribute(x); if (hasIgnore) { - logger.Trace($"[{nameof(MethodCollectorContext)}] StreamingHub type '{serviceType.FullName}' (HasIgnore; Skipped)"); return null; } - logger.Trace($"[{nameof(MethodCollectorContext)}] StreamingHub type '{serviceType.FullName}' (IfDirective={ifDirective})"); var methods = x.GetMembers() .OfType() @@ -47,7 +43,6 @@ IReadOnlyList GetStreamingHubs(MethodCollectorContex { if (HasIgnoreAttribute(symbol)) { - logger.Trace($"[{nameof(MethodCollectorContext)}] StreamingHub method '{symbol.Name}' in type '{serviceType.FullName}'. (HasIgnore; Skipped)"); return null; } return CreateHubMethodInfoFromMethodSymbol(serviceType, symbol); @@ -63,7 +58,6 @@ IReadOnlyList GetStreamingHubs(MethodCollectorContex .Select(y => CreateHubReceiverMethodInfoFromMethodSymbol(serviceType, receiverType, y)) .ToArray(); - logger.Trace($"[{nameof(MethodCollectorContext)}] StreamingHub Receiver type '{receiverType.FullName}'"); var receiver = new MagicOnionStreamingHubInfo.MagicOnionStreamingHubReceiverInfo(receiverType, receiverMethods, receiverInterfaceSymbol.GetDefinedGenerateIfCondition()); return new MagicOnionStreamingHubInfo(serviceType, methods, receiver, ifDirective); @@ -101,7 +95,6 @@ MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubMethodInfoFromMethod throw new InvalidOperationException($"StreamingHub method '{interfaceType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)}.{methodSymbol.Name}' has unsupported return type '{methodReturnType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.FullyQualified)}'."); } - logger.Trace($"[{nameof(MethodCollectorContext)}] StreamingHub method '{methodSymbol.Name}' in type '{interfaceType.FullName}'"); return new MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo( hubId, methodSymbol.Name, @@ -125,7 +118,6 @@ MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubReceiverMethodInfoFr throw new InvalidOperationException($"StreamingHub receiver method '{receiverType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)}.{methodSymbol.Name}' has unsupported return type '{methodReturnType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)}'."); } - logger.Trace($"[{nameof(MethodCollectorContext)}] StreamingHub receiver method '{methodSymbol.Name}' in type '{interfaceType.FullName}'"); return new MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo( hubId, methodSymbol.Name, @@ -147,19 +139,15 @@ IReadOnlyList GetServices(MethodCollectorContext ctx) var hasIgnore = HasIgnoreAttribute(x); if (hasIgnore) { - logger.Trace($"[{nameof(MethodCollectorContext)}] Service type '{serviceType.FullName}' (HasIgnore; Skipped)"); return null; } - logger.Trace($"[{nameof(MethodCollectorContext)}] Service type '{serviceType.FullName}' (IfDirective={ifDirective})"); - var methods = x.GetMembers() .OfType() .Select(symbol => { if (HasIgnoreAttribute(symbol)) { - logger.Trace($"[{nameof(MethodCollectorContext)}] Service method '{symbol.Name}' in type '{serviceType.FullName}'. (HasIgnore; Skipped)"); return null; } return CreateServiceMethodInfoFromMethodSymbol(serviceType, symbol); @@ -232,7 +220,6 @@ MagicOnionServiceInfo.MagicOnionServiceMethodInfo CreateServiceMethodInfoFromMet throw new InvalidOperationException($"ClientStreaming and DuplexStreaming must have no parameters. ({serviceType.FullName}.{methodSymbol.Name})"); } - logger.Trace($"[{nameof(MethodCollectorContext)}] Service method '{methodSymbol.Name}' ({methodType}) in type '{serviceType.FullName}' (IfDirective={ifDirective})"); return new MagicOnionServiceInfo.MagicOnionServiceMethodInfo( methodType, serviceType.Name, @@ -262,13 +249,11 @@ class MethodCollectorContext public IReadOnlyList ServiceAndHubInterfaces { get; } public IReadOnlyList ServiceInterfaces { get; } public IReadOnlyList HubInterfaces { get; } - public IMagicOnionGeneratorLogger Logger { get; } - public MethodCollectorContext(ReferenceSymbols referenceSymbols, IReadOnlyList serviceAndHubInterfaces, IMagicOnionGeneratorLogger logger) + public MethodCollectorContext(ReferenceSymbols referenceSymbols, IReadOnlyList serviceAndHubInterfaces) { ReferenceSymbols = referenceSymbols; ServiceAndHubInterfaces = serviceAndHubInterfaces; - Logger = logger; var serviceInterfaces = new HashSet(SymbolEqualityComparer.Default); var hubInterfaces = new HashSet(SymbolEqualityComparer.Default); @@ -296,7 +281,7 @@ public MethodCollectorContext(ReferenceSymbols referenceSymbols, IReadOnlyList x.TypeKind == TypeKind.Interface) @@ -311,10 +296,10 @@ public static MethodCollectorContext CreateFromCompilation(Compilation compilati }) .ToArray(); - return new MethodCollectorContext(referenceSymbols, serviceAndHubInterfaces, logger); + return new MethodCollectorContext(referenceSymbols, serviceAndHubInterfaces); } - public static MethodCollectorContext CreateFromInterfaceSymbols(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, IMagicOnionGeneratorLogger logger) + public static MethodCollectorContext CreateFromInterfaceSymbols(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) { var serviceAndHubInterfaces = interfaceSymbols .Where(x => x.TypeKind == TypeKind.Interface) @@ -329,7 +314,7 @@ public static MethodCollectorContext CreateFromInterfaceSymbols(ImmutableArray public class SerializationInfoCollector { - readonly IMagicOnionGeneratorLogger logger; readonly ISerializationFormatterNameMapper serializationFormatterNameMapper; - public SerializationInfoCollector(IMagicOnionGeneratorLogger logger, ISerializationFormatterNameMapper serializationFormatterNameMapper) + public SerializationInfoCollector(ISerializationFormatterNameMapper serializationFormatterNameMapper) { - this.logger = logger; this.serializationFormatterNameMapper = serializationFormatterNameMapper; } @@ -88,14 +86,12 @@ public MagicOnionSerializationInfoCollection Collect(IEnumerable" && mapper.WellKnownTypes.BuiltInNullableTypes.Contains(type.GenericArguments[0].FullName)) { - logger.Trace($"[{nameof(SerializationInfoCollector)}] Generic type '{type.FullName}'. Skip this because it is nullable."); continue; } if (mapper.TryMapGeneric(type, out var formatterName, out var formatterConstructorArgs)) { - logger.Trace($"[{nameof(SerializationInfoCollector)}] Generic type '{type.FullName}' (IfDirectives={string.Join(", ", typeWithDirectives.IfDirectives)})"); context.Generics.Add(new GenericSerializationInfo(type.FullName, formatterName, formatterConstructorArgs, typeWithDirectives.IfDirectives)); } } diff --git a/src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs b/src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs deleted file mode 100644 index 019abc02a..000000000 --- a/src/MagicOnion.Client.SourceGenerator/Internal/IMagicOnionGeneratorLogger.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace MagicOnion.Client.SourceGenerator.Internal; - -public interface IMagicOnionGeneratorLogger -{ - void Trace(string message); - void Information(string message); - void Error(string message, Exception? exception = null); -} - -public class MagicOnionGeneratorNullLogger : IMagicOnionGeneratorLogger -{ - public static IMagicOnionGeneratorLogger Instance { get; } = new MagicOnionGeneratorNullLogger(); - - public void Trace(string message) - { - } - - public void Information(string message) - { - } - - public void Error(string message, Exception? exception = null) - { - } -} - -public class MagicOnionGeneratorConsoleLogger : IMagicOnionGeneratorLogger -{ - readonly bool verbose; - - public MagicOnionGeneratorConsoleLogger(bool verbose) - { - this.verbose = verbose; - } - - public void Trace(string message) - { - if (verbose) - { - Console.WriteLine(message); - } - } - - public void Information(string message) - { - Console.WriteLine(message); - } - - public void Error(string message, Exception? exception = null) - { - Console.Error.WriteLine(message); - } -} diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index bdf60141a..8a218bada 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -33,7 +33,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) var (((options, interfaces), referenceSymbols), compilation) = values; if (referenceSymbols is null) return; - var compiler = new MagicOnionCompiler(MagicOnionGeneratorNullLogger.Instance); + var compiler = new MagicOnionCompiler(); var symbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); var generated = compiler.Generate(symbols, referenceSymbols, options, sourceProductionContext.CancellationToken); foreach (var (path, source) in generated) diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs index 560a2308f..d1b529145 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs @@ -17,13 +17,6 @@ public class MagicOnionCompiler { static readonly Encoding NoBomUtf8 = new UTF8Encoding(false); - readonly IMagicOnionGeneratorLogger logger; - - public MagicOnionCompiler(IMagicOnionGeneratorLogger logger) - { - this.logger = logger; - } - public IReadOnlyList<(string Path, string Source)> Generate(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, GeneratorOptions options, CancellationToken cancellationToken) { var outputs = new List<(string Path, string Source)>(); @@ -31,16 +24,6 @@ public MagicOnionCompiler(IMagicOnionGeneratorLogger logger) // Prepare args var namespaceDot = string.IsNullOrWhiteSpace(options.Namespace) ? string.Empty : options.Namespace + "."; - // Generator Start... - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:DisableAutoRegister: {options.DisableAutoRegister}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:Namespace: {options.Namespace}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:UserDefinedFormattersNamespace: {options.MessagePackFormatterNamespace}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] Option:SerializerType: {options.Serializer}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] Assembly version: {typeof(MagicOnionCompiler).Assembly.GetCustomAttribute().InformationalVersion}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] RuntimeInformation.OSDescription: {RuntimeInformation.OSDescription}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] RuntimeInformation.ProcessArchitecture: {RuntimeInformation.ProcessArchitecture}"); - logger.Trace($"[{nameof(MagicOnionCompiler)}] RuntimeInformation.FrameworkDescription: {RuntimeInformation.FrameworkDescription}"); - // Configure serialization (ISerializationFormatterNameMapper Mapper, string Namespace, string InitializerName, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) serialization = options.Serializer switch @@ -69,22 +52,17 @@ public MagicOnionCompiler(IMagicOnionGeneratorLogger logger) var sw = Stopwatch.StartNew(); sw.Restart(); - logger.Information("Collect services and methods Start"); - var collector = new MethodCollector(logger, cancellationToken); + var collector = new MethodCollector(cancellationToken); var serviceCollection = collector.Collect(interfaceSymbols, referenceSymbols); - logger.Information("Collect services and methods Complete:" + sw.Elapsed.ToString()); cancellationToken.ThrowIfCancellationRequested(); sw.Restart(); - logger.Information("Collect serialization information Start"); - var serializationInfoCollector = new SerializationInfoCollector(logger, serialization.Mapper); + var serializationInfoCollector = new SerializationInfoCollector(serialization.Mapper); var serializationInfoCollection = serializationInfoCollector.Collect(serviceCollection); - logger.Information("Collect serialization information Complete:" + sw.Elapsed.ToString()); cancellationToken.ThrowIfCancellationRequested(); - logger.Information("Code Generation Start"); sw.Restart(); var registerTemplate = new RegisterTemplate @@ -121,13 +99,6 @@ public MagicOnionCompiler(IMagicOnionGeneratorLogger logger) outputs.Add((GeneratePathFromNamespaceAndTypeName(hub.ServiceType.Namespace, hub.GetClientName()), WithAutoGenerated(x))); } - if (serviceCollection.Services.Count == 0 && serviceCollection.Hubs.Count == 0) - { - logger.Information("Generated result is empty, unexpected result?"); - } - - logger.Information("Code Generation Complete:" + sw.Elapsed.ToString()); - return outputs.OrderBy(x => x.Path).ToArray(); } @@ -155,8 +126,6 @@ void Output(string path, string text) { path = path.Replace("global::", ""); - logger.Information($"Write to {path}"); - var fi = new FileInfo(path); if (!fi.Directory.Exists) { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs index bf98fb81b..14dcf532a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs @@ -16,7 +16,7 @@ public SerializationInfoCollectorTest(ITestOutputHelper testOutputHelper) public void NonGenerics() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), @@ -40,7 +40,7 @@ public void NonGenerics() public void Nullable() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), @@ -63,7 +63,7 @@ public void Nullable() public void Generics_MergeIfDirectives() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), @@ -92,7 +92,7 @@ public void Generics_MergeIfDirectives() public void Generics_ManyTypeArguments() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), @@ -114,7 +114,7 @@ public void Generics_ManyTypeArguments() public void Enum() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType()), new string[] { }), @@ -150,7 +150,7 @@ public void Enum() public void KnownTypes_SkipBuiltInGenericTypes() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] {}), @@ -170,7 +170,7 @@ public void KnownTypes_SkipBuiltInGenericTypes() public void KnownTypes_Array_SkipBuiltInTypes() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), @@ -211,7 +211,7 @@ public void KnownTypes_Array_SkipBuiltInTypes() public void KnownTypes_Array_NonBuiltIn() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), @@ -237,7 +237,7 @@ public void KnownTypes_Array_NonBuiltIn() public void KnownTypes_Generics() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "List",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), @@ -279,7 +279,7 @@ public void KnownTypes_Generics() public void KnownTypes_Nullable() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), @@ -311,7 +311,7 @@ public void KnownTypes_Nullable() public void KnownTypes_ValueTuple() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), @@ -345,7 +345,7 @@ public void KnownTypes_ValueTuple() public void KnownTypes_Tuple() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), @@ -378,7 +378,7 @@ public void KnownTypes_Tuple() public void DynamicArgumentTuple() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), @@ -401,7 +401,7 @@ public void UserDefinedMessagePackSerializerFormattersNamespace() { // Arrange var userDefinedMessagePackFormattersNamespace = "MyFormatters"; - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(userDefinedMessagePackFormattersNamespace)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(userDefinedMessagePackFormattersNamespace)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), @@ -425,7 +425,7 @@ public void UserDefinedMessagePackSerializerFormattersNamespace() public void UserDefinedMessagePackSerializerFormattersNamespace_NotSpecified() { // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); + var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs deleted file mode 100644 index ed7a12c5e..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnionGeneratorTestOutputLogger.cs +++ /dev/null @@ -1,22 +0,0 @@ -using MagicOnion.Client.SourceGenerator.Internal; -using Xunit.Abstractions; - -namespace MagicOnion.Client.SourceGenerator.Tests; - -public class MagicOnionGeneratorTestOutputLogger : IMagicOnionGeneratorLogger -{ - readonly ITestOutputHelper outputHelper; - - public MagicOnionGeneratorTestOutputLogger(ITestOutputHelper outputHelper) - { - this.outputHelper = outputHelper; - } - -#if FALSE - public void Trace(string message) => outputHelper.WriteLine(message); -#else - public void Trace(string message) {} -#endif - public void Information(string message) => outputHelper.WriteLine(message); - public void Error(string message, Exception? exception = null) => outputHelper.WriteLine(message); -} From fe165a462a9af07ec5afe5d1c5a7ec96da45f85d Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 16:13:15 +0900 Subject: [PATCH 17/66] Cleanup unused codes --- .../CodeAnalysis/MagicOnionTypeInfo.cs | 18 ++++++------- .../CodeAnalysis/MethodCollector.cs | 18 ------------- .../SerializationFormatterNameMapper.cs | 5 ---- .../SerializationInfoCollector.cs | 1 - .../MagicOnionCompiler.cs | 25 ------------------- 5 files changed, 9 insertions(+), 58 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs index cb7f7cf08..bc4afcde8 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs @@ -20,7 +20,7 @@ public static class KnownTypes // ReSharper restore InconsistentNaming } - readonly SubType _subType; + readonly SubType subType; public string Namespace { get; } public string Name { get; } @@ -34,7 +34,7 @@ public MagicOnionTypeInfo GetGenericTypeDefinition() return MagicOnionTypeInfo.Create(Namespace, Name, Array.Empty(), IsValueType); } - public bool IsArray => _subType == SubType.Array; + public bool IsArray => subType == SubType.Array; public int ArrayRank { get; } public MagicOnionTypeInfo? ElementType { get; } @@ -43,9 +43,9 @@ public string FullName public string FullNameOpenType => ToDisplayName(DisplayNameFormat.FullyQualified | DisplayNameFormat.OpenGenerics); - public bool IsValueType => _subType == SubType.ValueType || _subType == SubType.Enum; + public bool IsValueType => subType == SubType.ValueType || subType == SubType.Enum; - public bool IsEnum => _subType == SubType.Enum; + public bool IsEnum => subType == SubType.Enum; public MagicOnionTypeInfo? UnderlyingType { get; } [Flags] @@ -59,7 +59,7 @@ public enum DisplayNameFormat FullyQualified = Namespace | Global, } - private enum SubType + enum SubType { None, ValueType, @@ -67,9 +67,9 @@ private enum SubType Array, } - private MagicOnionTypeInfo(string @namespace, string name, SubType subType = SubType.None, int arrayRank = 0, MagicOnionTypeInfo[]? genericArguments = null, MagicOnionTypeInfo? elementType = null, MagicOnionTypeInfo? underlyingType = null) + MagicOnionTypeInfo(string @namespace, string name, SubType subType = SubType.None, int arrayRank = 0, MagicOnionTypeInfo[]? genericArguments = null, MagicOnionTypeInfo? elementType = null, MagicOnionTypeInfo? underlyingType = null) { - _subType = subType; + this.subType = subType; Namespace = @namespace; Name = name; GenericArguments = genericArguments ?? Array.Empty(); @@ -231,7 +231,7 @@ public bool Equals(MagicOnionTypeInfo other) if (ReferenceEquals(this, other)) return true; return FullName == other.FullName && /* Namespace + Name + GenericArguments + ArrayRank + ElementType */ - _subType == other._subType && + subType == other.subType && ElementType! == other.ElementType! && UnderlyingType! == other.UnderlyingType!; } @@ -247,5 +247,5 @@ public override bool Equals(object obj) public static bool operator ==(MagicOnionTypeInfo a, MagicOnionTypeInfo b) => a?.Equals(b) ?? (b is null); public static bool operator !=(MagicOnionTypeInfo a, MagicOnionTypeInfo b) => !(a == b); - public override int GetHashCode() => (FullName /* Namespace + Name + GenericArguments + ArrayRank + ElementType */, _subType, ElementType, UnderlyingType).GetHashCode(); + public override int GetHashCode() => (FullName /* Namespace + Name + GenericArguments + ArrayRank + ElementType */, _subType: subType, ElementType, UnderlyingType).GetHashCode(); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index 396e0b151..948976ad9 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -281,24 +281,6 @@ public MethodCollectorContext(ReferenceSymbols referenceSymbols, IReadOnlyList x.TypeKind == TypeKind.Interface) - .Where(x => - { - var all = x.AllInterfaces; - if (all.Any(y => y.ApproximatelyEqual(referenceSymbols.IServiceMarker)) || all.Any(y => y.ApproximatelyEqual(referenceSymbols.IStreamingHubMarker))) - { - return true; - } - return false; - }) - .ToArray(); - - return new MethodCollectorContext(referenceSymbols, serviceAndHubInterfaces); - } - public static MethodCollectorContext CreateFromInterfaceSymbols(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) { var serviceAndHubInterfaces = interfaceSymbols diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs index 458e2d638..0fe9917bf 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationFormatterNameMapper.cs @@ -183,13 +183,8 @@ class MessagePackWellKnownSerializationTypes : IWellKnownSerializationTypes public class MemoryPackFormatterNameMapper : ISerializationFormatterNameMapper { - public IWellKnownSerializationTypes WellKnownTypes => MessagePackWellKnownSerializationTypes.Instance; - public MemoryPackFormatterNameMapper() - { - } - public bool TryMapGeneric(MagicOnionTypeInfo type, [NotNullWhen(true)] out string? formatterName, [NotNullWhen(true)] out string? formatterConstructorArgs) { formatterName = null; diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs index 0246930af..638b9ca32 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using MagicOnion.Client.SourceGenerator.Internal; namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs index d1b529145..30a65725e 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs @@ -2,21 +2,16 @@ using System.Collections.Immutable; using System.Diagnostics; -using System.Reflection; -using System.Runtime.InteropServices; using System.Text; using MagicOnion.Client.SourceGenerator.CodeAnalysis; using MagicOnion.Client.SourceGenerator.CodeGen; using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; -using MagicOnion.Client.SourceGenerator.Internal; using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator; public class MagicOnionCompiler { - static readonly Encoding NoBomUtf8 = new UTF8Encoding(false); - public IReadOnlyList<(string Path, string Source)> Generate(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, GeneratorOptions options, CancellationToken cancellationToken) { var outputs = new List<(string Path, string Source)>(); @@ -114,24 +109,4 @@ static string WithAutoGenerated(string s) sb.AppendLine(s); return sb.ToString(); } - - static string NormalizeNewLines(string content) - { - // The T4 generated code may be text with mixed line ending types. (CR + CRLF) - // We need to normalize the line ending type in each Operating Systems. (e.g. Windows=CRLF, Linux/macOS=LF) - return content.Replace("\r\n", "\n").Replace("\n", Environment.NewLine); - } - - void Output(string path, string text) - { - path = path.Replace("global::", ""); - - var fi = new FileInfo(path); - if (!fi.Directory.Exists) - { - fi.Directory.Create(); - } - - System.IO.File.WriteAllText(path, NormalizeNewLines(text), NoBomUtf8); - } } From 3d0a355bf44f34f704786555ab3ccbe02c482ece Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 16:41:49 +0900 Subject: [PATCH 18/66] Remove #if directive handling --- .../GenerateDefineDebugAttribute.cs | 1 + .../GenerateIfDirectiveAttribute.cs | 3 +- .../IMagicOnionCompileDirectiveTarget.cs | 7 - .../CodeAnalysis/IMagicOnionServiceInfo.cs | 2 +- .../CodeAnalysis/MagicOnionServiceInfo.cs | 15 +- .../MagicOnionStreamingHubInfo.cs | 22 +- .../CodeAnalysis/MethodCollector.cs | 20 +- .../CodeAnalysis/SerializationInfo.cs | 21 +- .../SerializationInfoCollector.cs | 139 ++---------- .../CodeGen/EnumTemplate.cs | 8 - .../CodeGen/EnumTemplate.tt | 6 - ...emoryPackFormatterRegistrationGenerator.cs | 9 +- .../MessagePackFormatterResolverGenerator.cs | 27 +-- .../CodeGen/RegisterTemplate.cs | 16 -- .../CodeGen/RegisterTemplate.tt | 12 - .../StaticMagicOnionClientGenerator.cs | 56 ++--- .../StaticStreamingHubClientGenerator.cs | 118 +++++----- .../Internal/IndentedTextWriterExtensions.cs | 29 --- .../Utils/RoslynExtensions.cs | 17 -- .../GenerateDefineDebugAttribute.cs | 1 + .../GenerateIfDirectiveAttribute.cs | 3 +- .../SerializationInfoCollectorTest.cs | 214 ++++++++---------- 22 files changed, 223 insertions(+), 523 deletions(-) delete mode 100644 src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs diff --git a/src/MagicOnion.Abstractions/GenerateDefineDebugAttribute.cs b/src/MagicOnion.Abstractions/GenerateDefineDebugAttribute.cs index e65cbe23b..1965ea622 100644 --- a/src/MagicOnion.Abstractions/GenerateDefineDebugAttribute.cs +++ b/src/MagicOnion.Abstractions/GenerateDefineDebugAttribute.cs @@ -10,6 +10,7 @@ namespace MagicOnion /// instruction for moc.exe, surround #if symbol with output code. /// [AttributeUsage(AttributeTargets.Method | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)] + [Obsolete("GenerateDefineDebug is no longer used from the generator. Use C# '#if' directive instead.")] public class GenerateDefineDebugAttribute : Attribute { public GenerateDefineDebugAttribute() diff --git a/src/MagicOnion.Abstractions/GenerateIfDirectiveAttribute.cs b/src/MagicOnion.Abstractions/GenerateIfDirectiveAttribute.cs index 8739ebb93..fd50cd6fa 100644 --- a/src/MagicOnion.Abstractions/GenerateIfDirectiveAttribute.cs +++ b/src/MagicOnion.Abstractions/GenerateIfDirectiveAttribute.cs @@ -6,10 +6,11 @@ namespace MagicOnion /// instruction for moc.exe, surround #if symbol with output code. /// [AttributeUsage(AttributeTargets.Method | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)] + [Obsolete("GenerateIfDirective is no longer used from the generator. Use C# '#if' directive instead.")] public class GenerateIfDirectiveAttribute : Attribute { public GenerateIfDirectiveAttribute(string condition) { } } -} \ No newline at end of file +} diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs deleted file mode 100644 index 10a869011..000000000 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionCompileDirectiveTarget.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; - -public interface IMagicOnionCompileDirectiveTarget -{ - string IfDirectiveCondition { get; } - bool HasIfDirectiveCondition { get; } -} diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionServiceInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionServiceInfo.cs index 06efd04bb..ed17a082d 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionServiceInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/IMagicOnionServiceInfo.cs @@ -1,6 +1,6 @@ namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; -public interface IMagicOnionServiceInfo : IMagicOnionCompileDirectiveTarget +public interface IMagicOnionServiceInfo { MagicOnionTypeInfo ServiceType { get; } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceInfo.cs index e0cac2d4d..8ec799ce7 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionServiceInfo.cs @@ -8,18 +8,14 @@ public class MagicOnionServiceInfo : IMagicOnionServiceInfo public MagicOnionTypeInfo ServiceType { get; } public IReadOnlyList Methods { get; } - public string IfDirectiveCondition { get; } - public bool HasIfDirectiveCondition => !string.IsNullOrEmpty(IfDirectiveCondition); - - public MagicOnionServiceInfo(MagicOnionTypeInfo serviceType, IReadOnlyList methods, string ifDirectiveCondition) + public MagicOnionServiceInfo(MagicOnionTypeInfo serviceType, IReadOnlyList methods) { ServiceType = serviceType; Methods = methods; - IfDirectiveCondition = ifDirectiveCondition; } [DebuggerDisplay("ServiceMethod: {MethodName,nq} ({MethodType,nq} {Path,nq}); MethodReturnType={MethodReturnType,nq}; RequestType={RequestType,nq}; ResponseType={ResponseType,nq}; Parameters={Parameters.Count,nq}")] - public class MagicOnionServiceMethodInfo : IMagicOnionCompileDirectiveTarget + public class MagicOnionServiceMethodInfo { public MethodType MethodType { get; } public string ServiceName { get; } @@ -70,9 +66,6 @@ public class MagicOnionServiceMethodInfo : IMagicOnionCompileDirectiveTarget /// public MagicOnionTypeInfo ResponseType { get; } - public string IfDirectiveCondition { get; } - public bool HasIfDirectiveCondition => !string.IsNullOrEmpty(IfDirectiveCondition); - public MagicOnionServiceMethodInfo( MethodType methodType, string serviceName, @@ -81,8 +74,7 @@ public MagicOnionServiceMethodInfo( IReadOnlyList parameters, MagicOnionTypeInfo methodReturnType, MagicOnionTypeInfo requestType, - MagicOnionTypeInfo responseType, - string ifDirectiveCondition) + MagicOnionTypeInfo responseType) { MethodType = methodType; ServiceName = serviceName; @@ -92,7 +84,6 @@ public MagicOnionServiceMethodInfo( MethodReturnType = methodReturnType; RequestType = requestType; ResponseType = responseType; - IfDirectiveCondition = ifDirectiveCondition; } } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionStreamingHubInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionStreamingHubInfo.cs index c90c850fb..a8a04f9f0 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionStreamingHubInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionStreamingHubInfo.cs @@ -9,19 +9,15 @@ public class MagicOnionStreamingHubInfo : IMagicOnionServiceInfo public IReadOnlyList Methods { get; } public MagicOnionStreamingHubReceiverInfo Receiver { get; } - public string IfDirectiveCondition { get; } - public bool HasIfDirectiveCondition => !string.IsNullOrEmpty(IfDirectiveCondition); - - public MagicOnionStreamingHubInfo(MagicOnionTypeInfo serviceType, IReadOnlyList methods, MagicOnionStreamingHubReceiverInfo receiver, string ifDirectiveCondition) + public MagicOnionStreamingHubInfo(MagicOnionTypeInfo serviceType, IReadOnlyList methods, MagicOnionStreamingHubReceiverInfo receiver) { ServiceType = serviceType; Methods = methods; Receiver = receiver; - IfDirectiveCondition = ifDirectiveCondition; } [DebuggerDisplay("HubMethod: {MethodName,nq}; HubId={HubId,nq}; MethodReturnType={MethodReturnType,nq}; RequestType={RequestType,nq}; ResponseType={ResponseType,nq}; Parameters={Parameters.Count,nq}")] - public class MagicOnionHubMethodInfo : IMagicOnionCompileDirectiveTarget + public class MagicOnionHubMethodInfo { public int HubId { get; } public string MethodName { get; } @@ -70,10 +66,7 @@ public class MagicOnionHubMethodInfo : IMagicOnionCompileDirectiveTarget /// public MagicOnionTypeInfo ResponseType { get; } - public string IfDirectiveCondition { get; } - public bool HasIfDirectiveCondition => !string.IsNullOrEmpty(IfDirectiveCondition); - - public MagicOnionHubMethodInfo(int hubId, string methodName, IReadOnlyList parameters, MagicOnionTypeInfo methodReturnType, MagicOnionTypeInfo requestType, MagicOnionTypeInfo responseType, string ifDirectiveCondition) + public MagicOnionHubMethodInfo(int hubId, string methodName, IReadOnlyList parameters, MagicOnionTypeInfo methodReturnType, MagicOnionTypeInfo requestType, MagicOnionTypeInfo responseType) { HubId = hubId; MethodName = methodName; @@ -81,24 +74,19 @@ public MagicOnionHubMethodInfo(int hubId, string methodName, IReadOnlyList Methods { get; } - public string IfDirectiveCondition { get; } - public bool HasIfDirectiveCondition => !string.IsNullOrEmpty(IfDirectiveCondition); - - public MagicOnionStreamingHubReceiverInfo(MagicOnionTypeInfo receiverType, IReadOnlyList methods, string ifDirectiveCondition) + public MagicOnionStreamingHubReceiverInfo(MagicOnionTypeInfo receiverType, IReadOnlyList methods) { ReceiverType = receiverType; Methods = methods; - IfDirectiveCondition = ifDirectiveCondition; } } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index 948976ad9..c5f1418a6 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -30,7 +30,6 @@ IReadOnlyList GetStreamingHubs(MethodCollectorContex .Select(x => { var serviceType = MagicOnionTypeInfo.CreateFromSymbol(x); - var ifDirective = x.GetDefinedGenerateIfCondition(); var hasIgnore = HasIgnoreAttribute(x); if (hasIgnore) { @@ -58,9 +57,9 @@ IReadOnlyList GetStreamingHubs(MethodCollectorContex .Select(y => CreateHubReceiverMethodInfoFromMethodSymbol(serviceType, receiverType, y)) .ToArray(); - var receiver = new MagicOnionStreamingHubInfo.MagicOnionStreamingHubReceiverInfo(receiverType, receiverMethods, receiverInterfaceSymbol.GetDefinedGenerateIfCondition()); + var receiver = new MagicOnionStreamingHubInfo.MagicOnionStreamingHubReceiverInfo(receiverType, receiverMethods); - return new MagicOnionStreamingHubInfo(serviceType, methods, receiver, ifDirective); + return new MagicOnionStreamingHubInfo(serviceType, methods, receiver); }) .Where(x => x is not null) .Cast() @@ -78,7 +77,6 @@ MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubMethodInfoFromMethod var hubId = GetHubMethodIdFromMethodSymbol(methodSymbol); var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); var methodParameters = CreateParameterInfoListFromMethodSymbol(methodSymbol); - var ifDirective = methodSymbol.GetDefinedGenerateIfCondition(); var requestType = CreateRequestTypeFromMethodParameters(methodParameters); var responseType = MagicOnionTypeInfo.KnownTypes.MessagePack_Nil; switch (methodReturnType.FullNameOpenType) @@ -101,8 +99,7 @@ MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubMethodInfoFromMethod methodParameters, methodReturnType, requestType, - responseType, - ifDirective + responseType ); } MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubReceiverMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, MagicOnionTypeInfo receiverType, IMethodSymbol methodSymbol) @@ -110,7 +107,6 @@ MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubReceiverMethodInfoFr var hubId = GetHubMethodIdFromMethodSymbol(methodSymbol); var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); var methodParameters = CreateParameterInfoListFromMethodSymbol(methodSymbol); - var ifDirective = methodSymbol.GetDefinedGenerateIfCondition(); var requestType = CreateRequestTypeFromMethodParameters(methodParameters); var responseType = MagicOnionTypeInfo.KnownTypes.MessagePack_Nil; if (methodReturnType != MagicOnionTypeInfo.KnownTypes.System_Void) @@ -124,8 +120,7 @@ MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubReceiverMethodInfoFr methodParameters, methodReturnType, requestType, - responseType, - ifDirective + responseType ); } @@ -135,7 +130,6 @@ IReadOnlyList GetServices(MethodCollectorContext ctx) .Select(x => { var serviceType = MagicOnionTypeInfo.CreateFromSymbol(x); - var ifDirective = x.GetDefinedGenerateIfCondition(); var hasIgnore = HasIgnoreAttribute(x); if (hasIgnore) { @@ -156,7 +150,7 @@ IReadOnlyList GetServices(MethodCollectorContext ctx) .Cast() .ToArray(); - return new MagicOnionServiceInfo(serviceType, methods, ifDirective); + return new MagicOnionServiceInfo(serviceType, methods); }) .Where(x => x is not null) .Cast() @@ -168,7 +162,6 @@ MagicOnionServiceInfo.MagicOnionServiceMethodInfo CreateServiceMethodInfoFromMet { var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); var methodParameters = CreateParameterInfoListFromMethodSymbol(methodSymbol); - var ifDirective = methodSymbol.GetDefinedGenerateIfCondition(); var methodType = MethodType.Other; var requestType = CreateRequestTypeFromMethodParameters(methodParameters); var responseType = MagicOnionTypeInfo.KnownTypes.System_Void; @@ -228,8 +221,7 @@ MagicOnionServiceInfo.MagicOnionServiceMethodInfo CreateServiceMethodInfoFromMet methodParameters, methodReturnType, requestType, - responseType, - ifDirective + responseType ); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfo.cs index 93833967b..c68ce2fe5 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfo.cs @@ -6,9 +6,6 @@ public interface ISerializationFormatterRegisterInfo string FullName { get; } string FormatterName { get; } string FormatterConstructorArgs { get; } - - IReadOnlyList IfDirectiveConditions { get; } - bool HasIfDirectiveConditions { get; } } public class GenericSerializationInfo : ISerializationFormatterRegisterInfo @@ -18,15 +15,11 @@ public class GenericSerializationInfo : ISerializationFormatterRegisterInfo public string FormatterName { get; } public string FormatterConstructorArgs { get; } - public IReadOnlyList IfDirectiveConditions { get; } - public bool HasIfDirectiveConditions => IfDirectiveConditions.Any(); - - public GenericSerializationInfo(string fullName, string formatterName, string formatterConstructorArgs, IReadOnlyList ifDirectiveConditions) + public GenericSerializationInfo(string fullName, string formatterName, string formatterConstructorArgs) { FullName = fullName; FormatterName = formatterName; FormatterConstructorArgs = formatterConstructorArgs; - IfDirectiveConditions = ifDirectiveConditions; } } @@ -40,16 +33,12 @@ public class EnumSerializationInfo : ISerializationFormatterRegisterInfo public string FormatterName => $"{Name.Replace(".", "_")}Formatter"; public string FormatterConstructorArgs => "()"; - public IReadOnlyList IfDirectiveConditions { get; } - public bool HasIfDirectiveConditions => IfDirectiveConditions.Any(); - - public EnumSerializationInfo(string @namespace, string name, string fullName, string underlyingType, IReadOnlyList ifDirectiveConditions) + public EnumSerializationInfo(string @namespace, string name, string fullName, string underlyingType) { Namespace = @namespace; Name = name; FullName = fullName; UnderlyingType = underlyingType; - IfDirectiveConditions = ifDirectiveConditions; } } @@ -60,12 +49,8 @@ public class SerializationTypeHintInfo : ISerializationFormatterRegisterInfo string ISerializationFormatterRegisterInfo.FormatterName => string.Empty; // Dummy string ISerializationFormatterRegisterInfo.FormatterConstructorArgs => string.Empty; // Dummy - public IReadOnlyList IfDirectiveConditions { get; } - public bool HasIfDirectiveConditions => IfDirectiveConditions.Any(); - - public SerializationTypeHintInfo(string fullName, IReadOnlyList ifDirectiveConditions) + public SerializationTypeHintInfo(string fullName) { FullName = fullName; - IfDirectiveConditions = ifDirectiveConditions; } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs index 638b9ca32..99765a7b6 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs @@ -17,17 +17,16 @@ public SerializationInfoCollector(ISerializationFormatterNameMapper serializatio public MagicOnionSerializationInfoCollection Collect(MagicOnionServiceCollection serviceCollection) => Collect(EnumerateTypes(serviceCollection)); - static IEnumerable EnumerateTypes(MagicOnionServiceCollection serviceCollection) + static IEnumerable EnumerateTypes(MagicOnionServiceCollection serviceCollection) { return Enumerable.Concat( serviceCollection.Services.SelectMany(service => { return service.Methods.SelectMany(method => { - var ifDirectives = new[] { service.IfDirectiveCondition, method.IfDirectiveCondition }.Distinct().Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); return Enumerable.Concat( - EnumerateTypes(method.ResponseType, ifDirectives), - EnumerateTypes(method.RequestType, ifDirectives) + EnumerateTypes(method.ResponseType), + EnumerateTypes(method.RequestType) ); }); }), @@ -36,33 +35,31 @@ static IEnumerable EnumerateTypes(MagicOnionServiceCollect return Enumerable.Concat( hub.Receiver.Methods.SelectMany(method => { - var ifDirectives = new[] { hub.IfDirectiveCondition, method.IfDirectiveCondition }.Distinct().Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); return Enumerable.Concat( - EnumerateTypes(method.ResponseType, ifDirectives), - EnumerateTypes(method.RequestType, ifDirectives) + EnumerateTypes(method.ResponseType), + EnumerateTypes(method.RequestType) ); }), hub.Methods.SelectMany(method => { - var ifDirectives = new[] { hub.IfDirectiveCondition, method.IfDirectiveCondition }.Distinct().Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); return Enumerable.Concat( - EnumerateTypes(method.ResponseType, ifDirectives), - EnumerateTypes(method.RequestType, ifDirectives) + EnumerateTypes(method.ResponseType), + EnumerateTypes(method.RequestType) ); }) ); }) ); } - static IEnumerable EnumerateTypes(MagicOnionTypeInfo type, IReadOnlyList ifDirectives) + static IEnumerable EnumerateTypes(MagicOnionTypeInfo type) { - yield return new TypeWithIfDirectives(type, ifDirectives); + yield return type; if (type.HasGenericArguments) { foreach (var genericTypeArg in type.GenericArguments) { - foreach (var t in EnumerateTypes(genericTypeArg, ifDirectives)) + foreach (var t in EnumerateTypes(genericTypeArg)) { yield return t; } @@ -70,19 +67,18 @@ static IEnumerable EnumerateTypes(MagicOnionTypeInfo type, } } - public MagicOnionSerializationInfoCollection Collect(IEnumerable types) + public MagicOnionSerializationInfoCollection Collect(IEnumerable types) { var mapper = serializationFormatterNameMapper; var context = new SerializationInfoCollectorContext(); - var flattened = types.SelectMany(x => x.Type.EnumerateDependentTypes(includesSelf: true).Select(y => new TypeWithIfDirectives(y, x.IfDirectives))); - var proceeded = new HashSet(); + var flattened = types.SelectMany(x => x.EnumerateDependentTypes(includesSelf: true)); + var proceeded = new HashSet(); - foreach (var typeWithDirectives in flattened) + foreach (var type in flattened) { - if (proceeded.Contains(typeWithDirectives)) continue; - proceeded.Add(typeWithDirectives); + if (proceeded.Contains(type)) continue; + proceeded.Add(type); - var type = typeWithDirectives.Type; if (mapper.WellKnownTypes.BuiltInTypes.Contains(type.FullName)) { continue; @@ -95,8 +91,7 @@ public MagicOnionSerializationInfoCollection Collect(IEnumerable new SerializationTypeHintInfo(x.Type.FullName, x.IfDirectives))) + context.Enums, + context.Generics, + proceeded.Select(x => new SerializationTypeHintInfo(x.FullName)).ToList() ); } - static GenericSerializationInfo[] MergeResolverRegisterInfo(IEnumerable serializationInfoSet) - => MergeResolverRegisterInfo(serializationInfoSet, (serializationInfo, serializationInfoCandidate) => - new GenericSerializationInfo( - serializationInfo.FullName, - serializationInfo.FormatterName, - serializationInfo.FormatterConstructorArgs, - serializationInfo.IfDirectiveConditions.Concat(serializationInfoCandidate.IfDirectiveConditions).ToArray() - ) - ); - - static EnumSerializationInfo[] MergeResolverRegisterInfo(IEnumerable serializationInfoSet) - => MergeResolverRegisterInfo(serializationInfoSet, (serializationInfo, serializationInfoCandidate) => - new EnumSerializationInfo( - serializationInfo.Namespace, - serializationInfo.Name, - serializationInfo.FullName, - serializationInfo.UnderlyingType, - serializationInfo.IfDirectiveConditions.Concat(serializationInfoCandidate.IfDirectiveConditions).ToArray() - ) - ); - - static SerializationTypeHintInfo[] MergeSerializationTypeHintInfo(IEnumerable serializationInfoSet) - => MergeResolverRegisterInfo(serializationInfoSet, (serializationInfo, serializationInfoCandidate) => - new SerializationTypeHintInfo( - serializationInfo.FullName, - serializationInfo.IfDirectiveConditions.Concat(serializationInfoCandidate.IfDirectiveConditions).ToArray() - ) - ); - - /// - /// Merge `#if` directives by type of serialization target. - /// - /// - /// * Foo --> Foo
- /// * Bar, Bar (#if CONST_1) --> Bar
- /// * Baz (#if CONST_1), Baz (#if CONST_2) --> Baz (#if CONST_1 || CONST_2)
- ///
- static T[] MergeResolverRegisterInfo(IEnumerable serializationInfoSet, Func mergeFunc) - where T : ISerializationFormatterRegisterInfo - { - // The priority of the generation depends on the `#if` directive - // If a serialization info has no `#if` conditions, we always use it. If there is more than one with the condition, it is merged. - var candidates = new Dictionary(); - foreach (var serializationInfo in serializationInfoSet) - { - if (serializationInfo.HasIfDirectiveConditions && candidates.TryGetValue(serializationInfo.FullName, out var serializationInfoCandidate)) - { - if (!serializationInfoCandidate.HasIfDirectiveConditions) - { - // If the candidate serialization info has no `#if` conditions, we keep to use it. - continue; - } - - // Merge `IfDirectiveConditions` - candidates[serializationInfo.FullName] = mergeFunc(serializationInfo, serializationInfoCandidate); - } - else - { - // The serialization info has no `#if` conditions, or is found first. - candidates[serializationInfo.FullName] = serializationInfo; - } - } - - return candidates.Values.ToArray(); - } - class SerializationInfoCollectorContext { public List Enums { get; } = new List(); public List Generics { get; } = new List(); } - - [DebuggerDisplay("{Type,nq}")] - public class TypeWithIfDirectives : IEquatable - { - public MagicOnionTypeInfo Type { get; } - public IReadOnlyList IfDirectives { get; } - - public TypeWithIfDirectives(MagicOnionTypeInfo type, IReadOnlyList ifDirectives) - { - Type = type; - IfDirectives = ifDirectives; - } - - public bool Equals(TypeWithIfDirectives other) - { - if (other is null) return false; - return (other.Type == this.Type && Enumerable.SequenceEqual(other.IfDirectives, this.IfDirectives)); - } - - public override int GetHashCode() - { - return (Type, string.Join(";", IfDirectives)).GetHashCode(); - } - } } public class MagicOnionSerializationInfoCollection diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs index 1fb6b6db2..9ec95eb39 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs @@ -31,11 +31,6 @@ public virtual string TransformText() this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); this.Write("\r\n{\r\n using System;\r\n using MessagePack;\r\n\r\n"); foreach (var info in EnumSerializationInfos) { - if (info.HasIfDirectiveConditions) { - this.Write("#if "); - this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(" || ", info.IfDirectiveConditions.Select(y => $"({y})")))); - this.Write("\r\n"); - } this.Write(" public sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(info.FormatterName)); this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); @@ -53,9 +48,6 @@ public virtual string TransformText() this.Write(")reader.Read"); this.Write(this.ToStringHelper.ToStringWithCulture(info.UnderlyingType)); this.Write("();\r\n }\r\n }\r\n"); - if (info.HasIfDirectiveConditions) { - this.Write("#endif\r\n"); - } } this.Write("\r\n}\r\n\r\n#pragma warning restore 168\r\n#pragma warning restore 219\r\n#pragma warning " + "restore 414\r\n#pragma warning restore 612\r\n#pragma warning restore 618\r\n"); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt b/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt index 4fa10bc03..6921d23b1 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt @@ -16,9 +16,6 @@ namespace <#= Namespace #> using MessagePack; <# foreach (var info in EnumSerializationInfos) { #> -<# if (info.HasIfDirectiveConditions) { #> -#if <#= string.Join(" || ", info.IfDirectiveConditions.Select(y => $"({y})")) #> -<# } #> public sealed class <#= info.FormatterName #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= info.FullName #>> { public void Serialize(ref MessagePackWriter writer, <#= info.FullName #> value, MessagePackSerializerOptions options) @@ -31,9 +28,6 @@ namespace <#= Namespace #> return (<#= info.FullName #>)reader.Read<#= info.UnderlyingType #>(); } } -<# if (info.HasIfDirectiveConditions) { #> -#endif -<# } #> <# } #> } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs index a70d3b31e..745af89cf 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs @@ -61,12 +61,9 @@ public static void RegisterFormatters() { foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) { - using (ctx.TextWriter.IfDirective(string.Join(" || ", resolverInfo.IfDirectiveConditions.Select(y => $"({y})")))) - { - ctx.TextWriter.WriteLines($$""" - global::MemoryPack.MemoryPackFormatterProvider.Register(new {{(resolverInfo.FormatterName.StartsWith("global::") || string.IsNullOrWhiteSpace(ctx.FormatterNamespace) ? "" : ctx.FormatterNamespace + ".") + resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}); - """); - } + ctx.TextWriter.WriteLines($$""" + global::MemoryPack.MemoryPackFormatterProvider.Register(new {{(resolverInfo.FormatterName.StartsWith("global::") || string.IsNullOrWhiteSpace(ctx.FormatterNamespace) ? "" : ctx.FormatterNamespace + ".") + resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}); + """); } } ctx.TextWriter.WriteLines($$""" diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs index 33c50c781..106f8192d 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs @@ -102,12 +102,9 @@ internal static class {{ctx.InitializerName}}GetFormatterHelper { foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) { - using (ctx.TextWriter.IfDirective(string.Join(" || ", resolverInfo.IfDirectiveConditions.Select(y => $"({y})")))) - { - ctx.TextWriter.WriteLines($$""" - {typeof({{resolverInfo.FullName}}), {{index}} }, - """); - } + ctx.TextWriter.WriteLines($$""" + {typeof({{resolverInfo.FullName}}), {{index}} }, + """); } } // lookup = new ... ctx.TextWriter.WriteLine("};"); @@ -132,12 +129,9 @@ internal static object GetFormatter(Type t) { foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) { - using (ctx.TextWriter.IfDirective(string.Join(" || ", resolverInfo.IfDirectiveConditions.Select(y => $"({y})")))) - { - ctx.TextWriter.WriteLines($$""" - case {{index}}: return new {{(resolverInfo.FormatterName.StartsWith("global::") || string.IsNullOrWhiteSpace(ctx.FormatterNamespace) ? "" : ctx.FormatterNamespace + ".") + resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}; - """); - } + ctx.TextWriter.WriteLines($$""" + case {{index}}: return new {{(resolverInfo.FormatterName.StartsWith("global::") || string.IsNullOrWhiteSpace(ctx.FormatterNamespace) ? "" : ctx.FormatterNamespace + ".") + resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}; + """); } ctx.TextWriter.WriteLine("default: return null;"); } // switch (key) @@ -165,12 +159,9 @@ internal static void Register() { foreach (var typeHint in ctx.TypeHints) { - using (ctx.TextWriter.IfDirective(string.Join(" || ", typeHint.IfDirectiveConditions.Select(y => $"({y})")))) - { - ctx.TextWriter.WriteLines($$""" - _ = {{ctx.InitializerName}}.Instance.GetFormatter<{{typeHint.FullName}}>(); - """); - } + ctx.TextWriter.WriteLines($$""" + _ = {{ctx.InitializerName}}.Instance.GetFormatter<{{typeHint.FullName}}>(); + """); } } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs index 0fc239fa3..ef8dd7c38 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs @@ -92,11 +92,6 @@ public static partial class MagicOnionInitializer " object factory = default(global::MagicOnion.Client.MagicOnionClientFactor" + "yDelegate);\r\n\r\n"); foreach(var serviceInfo in Services) { - if(serviceInfo.HasIfDirectiveCondition) { - this.Write("#if "); - this.Write(this.ToStringHelper.ToStringWithCulture(serviceInfo.IfDirectiveCondition)); - this.Write("\r\n"); - } this.Write(" if (typeof(T) == typeof("); this.Write(this.ToStringHelper.ToStringWithCulture(serviceInfo.ServiceType.FullName)); this.Write("))\r\n {\r\n factory = ((global::MagicOnion.Client." + @@ -105,9 +100,6 @@ public static partial class MagicOnionInitializer this.Write(">)((x, y) => new "); this.Write(this.ToStringHelper.ToStringWithCulture(serviceInfo.GetClientFullName())); this.Write("(x, y)));\r\n }\r\n"); - if(serviceInfo.HasIfDirectiveCondition) { - this.Write("#endif\r\n"); - } } // foreach this.Write(@" Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } @@ -123,11 +115,6 @@ static StreamingHubClientFactoryCache() "); foreach(var hubInfo in Hubs) { - if(hubInfo.HasIfDirectiveCondition) { - this.Write("#if "); - this.Write(this.ToStringHelper.ToStringWithCulture(hubInfo.IfDirectiveCondition)); - this.Write("\r\n"); - } this.Write(" if (typeof(TStreamingHub) == typeof("); this.Write(this.ToStringHelper.ToStringWithCulture(hubInfo.ServiceType.FullName)); this.Write(") && typeof(TReceiver) == typeof("); @@ -140,9 +127,6 @@ static StreamingHubClientFactoryCache() this.Write(">)((a, _, b, c, d, e) => new "); this.Write(this.ToStringHelper.ToStringWithCulture(hubInfo.GetClientFullName())); this.Write("(a, b, c, d, e)));\r\n }\r\n"); - if(hubInfo.HasIfDirectiveCondition) { - this.Write("#endif\r\n"); - } } // foreach this.Write(@" Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt index a260a1001..4c17d6f2b 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt @@ -73,16 +73,10 @@ namespace <#= Namespace #> object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); <# foreach(var serviceInfo in Services) { #> -<# if(serviceInfo.HasIfDirectiveCondition) { #> -#if <#= serviceInfo.IfDirectiveCondition #> -<# } #> if (typeof(T) == typeof(<#= serviceInfo.ServiceType.FullName #>)) { factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate<<#= serviceInfo.ServiceType.FullName #>>)((x, y) => new <#= serviceInfo.GetClientFullName() #>(x, y))); } -<# if(serviceInfo.HasIfDirectiveCondition) { #> -#endif -<# } #> <# } // foreach #> Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } @@ -97,16 +91,10 @@ namespace <#= Namespace #> object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); <# foreach(var hubInfo in Hubs) { #> -<# if(hubInfo.HasIfDirectiveCondition) { #> -#if <#= hubInfo.IfDirectiveCondition #> -<# } #> if (typeof(TStreamingHub) == typeof(<#= hubInfo.ServiceType.FullName #>) && typeof(TReceiver) == typeof(<#= hubInfo.Receiver.ReceiverType.FullName #>)) { factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate<<#= hubInfo.ServiceType.FullName #>, <#= hubInfo.Receiver.ReceiverType.FullName #>>)((a, _, b, c, d, e) => new <#= hubInfo.GetClientFullName() #>(a, b, c, d, e))); } -<# if(hubInfo.HasIfDirectiveCondition) { #> -#endif -<# } #> <# } // foreach #> Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs index 81088bd9e..5c20322f0 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs @@ -31,12 +31,9 @@ public static string Build(IEnumerable services) { var buildContext = new ServiceClientBuildContext(serviceInfo, textWriter); - using (textWriter.IfDirective(serviceInfo.IfDirectiveCondition)) // #if ... - { - EmitPreamble(buildContext); - EmitServiceClientClass(buildContext); - EmitPostscript(buildContext); - } // #endif + EmitPreamble(buildContext); + EmitServiceClientClass(buildContext); + EmitPostscript(buildContext); } return baseWriter.ToString(); @@ -162,26 +159,23 @@ static void EmitServiceMethods(ServiceClientBuildContext ctx) // => this.core.MethodName.InvokeDuplexStreaming(this, "ServiceName/MethodName"); foreach (var method in ctx.Service.Methods) { - using (ctx.TextWriter.IfDirective(method.IfDirectiveCondition)) // #if ... + var invokeRequestParameters = method.Parameters.Count switch { - var invokeRequestParameters = method.Parameters.Count switch - { - // Invoker for ClientStreaming, DuplexStreaming method has no request parameter. - _ when (method.MethodType != MethodType.Unary && method.MethodType != MethodType.ServerStreaming) => $"", - // Nil.Default - 0 => $", global::MessagePack.Nil.Default", - // arg0 - 1 => $", {method.Parameters[0].Name}", - // new DynamicArgumentTuple(arg1, arg2, ...) - _ => $", {method.Parameters.ToNewDynamicArgumentTuple()}", - }; - var hasNonGenericUnaryResult = method.MethodReturnType == MagicOnionTypeInfo.KnownTypes.MagicOnion_UnaryResult; - - ctx.TextWriter.WriteLines($""" - public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) - => this.core.{method.MethodName}.Invoke{method.MethodType}{(hasNonGenericUnaryResult ? "NonGeneric" : "")}(this, "{method.Path}"{invokeRequestParameters}); - """); - } // #endif + // Invoker for ClientStreaming, DuplexStreaming method has no request parameter. + _ when (method.MethodType != MethodType.Unary && method.MethodType != MethodType.ServerStreaming) => $"", + // Nil.Default + 0 => $", global::MessagePack.Nil.Default", + // arg0 + 1 => $", {method.Parameters[0].Name}", + // new DynamicArgumentTuple(arg1, arg2, ...) + _ => $", {method.Parameters.ToNewDynamicArgumentTuple()}", + }; + var hasNonGenericUnaryResult = method.MethodReturnType == MagicOnionTypeInfo.KnownTypes.MagicOnion_UnaryResult; + + ctx.TextWriter.WriteLines($""" + public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) + => this.core.{method.MethodName}.Invoke{method.MethodType}{(hasNonGenericUnaryResult ? "NonGeneric" : "")}(this, "{method.Path}"{invokeRequestParameters}); + """); } } @@ -208,10 +202,7 @@ static void EmitClientCore(ServiceClientBuildContext ctx) // public RawMethodInvoker MethodName; foreach (var method in ctx.Service.Methods) { - using (ctx.TextWriter.IfDirective(method.IfDirectiveCondition)) // #if ... - { - ctx.TextWriter.WriteLine($"public global::MagicOnion.Client.Internal.RawMethodInvoker<{method.RequestType.FullName}, {method.ResponseType.FullName}> {method.MethodName};"); - } // #endif + ctx.TextWriter.WriteLine($"public global::MagicOnion.Client.Internal.RawMethodInvoker<{method.RequestType.FullName}, {method.ResponseType.FullName}> {method.MethodName};"); } // public ClientCore(IMagicOnionSerializerProvider serializerProvider) { @@ -222,11 +213,8 @@ static void EmitClientCore(ServiceClientBuildContext ctx) // MethodName = RawMethodInvoker.Create_XXXType_XXXType(MethodType, ServiceName, MethodName, serializerProvider); foreach (var method in ctx.Service.Methods) { - using (ctx.TextWriter.IfDirective(method.IfDirectiveCondition)) // #if ... - { - var createMethodVariant = $"{(method.RequestType.IsValueType ? "Value" : "Ref")}Type_{(method.ResponseType.IsValueType ? "Value" : "Ref")}Type"; - ctx.TextWriter.WriteLine($"this.{method.MethodName} = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_{createMethodVariant}<{method.RequestType.FullName}, {method.ResponseType.FullName}>(global::Grpc.Core.MethodType.{method.MethodType}, \"{method.ServiceName}\", \"{method.MethodName}\", serializerProvider);"); - } // #endif + var createMethodVariant = $"{(method.RequestType.IsValueType ? "Value" : "Ref")}Type_{(method.ResponseType.IsValueType ? "Value" : "Ref")}Type"; + ctx.TextWriter.WriteLine($"this.{method.MethodName} = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_{createMethodVariant}<{method.RequestType.FullName}, {method.ResponseType.FullName}>(global::Grpc.Core.MethodType.{method.MethodType}, \"{method.ServiceName}\", \"{method.MethodName}\", serializerProvider);"); } } ctx.TextWriter.WriteLine("}"); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs index 6f3ad6b8b..5bf372d6d 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs @@ -31,12 +31,9 @@ public static string Build(IEnumerable hubs) { var buildContext = new StreamingHubClientBuildContext(hubInfo, textWriter); - using (textWriter.IfDirective(hubInfo.IfDirectiveCondition)) // #if ... - { - EmitPreamble(buildContext); - EmitHubClientClass(buildContext); - EmitPostscript(buildContext); - } // #endif + EmitPreamble(buildContext); + EmitHubClientClass(buildContext); + EmitPostscript(buildContext); } return baseWriter.ToString(); @@ -160,43 +157,40 @@ static void EmitHubMethods(StreamingHubClientBuildContext ctx, bool isFireAndFor // => WriteMessageWithResponseAsync, int>(FNV1A32.GetHashCode(nameof(MethodParameter_Many)), new DynamicArgumentTuple(arg0, arg1)); foreach (var method in ctx.Hub.Methods) { - using (ctx.TextWriter.IfDirective(method.IfDirectiveCondition)) // #if ... + var writeMessageParameters = method.Parameters.Count switch { - var writeMessageParameters = method.Parameters.Count switch - { - // Nil.Default - 0 => $", global::MessagePack.Nil.Default", - // arg0 - 1 => $", {method.Parameters[0].Name}", - // new DynamicArgumentTuple(arg1, arg2, ...) - _ => $", {method.Parameters.ToNewDynamicArgumentTuple()}", - }; + // Nil.Default + 0 => $", global::MessagePack.Nil.Default", + // arg0 + 1 => $", {method.Parameters[0].Name}", + // new DynamicArgumentTuple(arg1, arg2, ...) + _ => $", {method.Parameters.ToNewDynamicArgumentTuple()}", + }; - if (method.MethodReturnType == MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_ValueTask) - { - // ValueTask - ctx.TextWriter.WriteLines($""" - public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) - => new global::System.Threading.Tasks.ValueTask({(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters})); - """); - } - else if (method.MethodReturnType.HasGenericArguments && method.MethodReturnType.GetGenericTypeDefinition() == MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_ValueTask) - { - // ValueTask - ctx.TextWriter.WriteLines($""" - public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) - => new global::System.Threading.Tasks.ValueTask<{method.ResponseType.FullName}>({(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters})); - """); - } - else - { - // Task, Task - ctx.TextWriter.WriteLines($""" - public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) - => {(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters}); - """); - } - } // #endif + if (method.MethodReturnType == MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_ValueTask) + { + // ValueTask + ctx.TextWriter.WriteLines($""" + public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) + => new global::System.Threading.Tasks.ValueTask({(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters})); + """); + } + else if (method.MethodReturnType.HasGenericArguments && method.MethodReturnType.GetGenericTypeDefinition() == MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_ValueTask) + { + // ValueTask + ctx.TextWriter.WriteLines($""" + public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) + => new global::System.Threading.Tasks.ValueTask<{method.ResponseType.FullName}>({(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters})); + """); + } + else + { + // Task, Task + ctx.TextWriter.WriteLines($""" + public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) + => {(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters}); + """); + } } ctx.TextWriter.WriteLine(); @@ -214,24 +208,21 @@ static void EmitOnBroadcastEvent(StreamingHubClientBuildContext ctx) { foreach (var method in ctx.Hub.Receiver.Methods) { - using (ctx.TextWriter.IfDirective(method.IfDirectiveCondition)) + var methodArgs = method.Parameters.Count switch { - var methodArgs = method.Parameters.Count switch - { - 0 => "", - 1 => "value", - _ => string.Join(", ", Enumerable.Range(1, method.Parameters.Count).Select(x => $"value.Item{x}")) - }; + 0 => "", + 1 => "value", + _ => string.Join(", ", Enumerable.Range(1, method.Parameters.Count).Select(x => $"value.Item{x}")) + }; - ctx.TextWriter.WriteLines($$""" - case {{method.HubId}}: // {{method.MethodReturnType.ToDisplayName()}} {{method.MethodName}}({{method.Parameters.ToMethodSignaturize()}}) - { - var value = base.Deserialize<{{method.RequestType.FullName}}>(data); - receiver.{{method.MethodName}}({{methodArgs}}); - } - break; - """); - } + ctx.TextWriter.WriteLines($$""" + case {{method.HubId}}: // {{method.MethodReturnType.ToDisplayName()}} {{method.MethodName}}({{method.Parameters.ToMethodSignaturize()}}) + { + var value = base.Deserialize<{{method.RequestType.FullName}}>(data); + receiver.{{method.MethodName}}({{methodArgs}}); + } + break; + """); } } ctx.TextWriter.WriteLine("}"); @@ -252,14 +243,11 @@ static void EmitOnResponseEvent(StreamingHubClientBuildContext ctx) { foreach (var method in ctx.Hub.Methods) { - using (ctx.TextWriter.IfDirective(method.IfDirectiveCondition)) - { - ctx.TextWriter.WriteLines($$""" - case {{method.HubId}}: // {{method.MethodReturnType.ToDisplayName()}} {{method.MethodName}}({{method.Parameters.ToMethodSignaturize()}}) - base.SetResultForResponse<{{method.ResponseType.FullName}}>(taskCompletionSource, data); - break; - """); - } + ctx.TextWriter.WriteLines($$""" + case {{method.HubId}}: // {{method.MethodReturnType.ToDisplayName()}} {{method.MethodName}}({{method.Parameters.ToMethodSignaturize()}}) + base.SetResultForResponse<{{method.ResponseType.FullName}}>(taskCompletionSource, data); + break; + """); } } ctx.TextWriter.WriteLine("}"); diff --git a/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs index ef7d9911d..2bd97adf8 100644 --- a/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs @@ -34,33 +34,4 @@ public void Dispose() textWriter.Indent -= depth; } } - - public static IfBlock IfDirective(this IndentedTextWriter textWriter, string conditions) - { - if (!string.IsNullOrWhiteSpace(conditions)) - { - textWriter.WriteLineNoTabs($"#if {conditions}"); - } - return new IfBlock(textWriter, conditions); - } - - public readonly struct IfBlock : IDisposable - { - readonly IndentedTextWriter textWriter; - readonly string conditions; - - public IfBlock(IndentedTextWriter textWriter, string conditions) - { - this.textWriter = textWriter; - this.conditions = conditions; - } - - public void Dispose() - { - if (!string.IsNullOrWhiteSpace(conditions)) - { - textWriter.WriteLineNoTabs($"#endif // {conditions}"); - } - } - } } diff --git a/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs index 582dc3b34..ec077e575 100644 --- a/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs @@ -137,21 +137,4 @@ public static bool ApproximatelyEqual(this ITypeSymbol left, ITypeSymbol right) return SymbolEqualityComparer.Default.Equals(left, right); } } - - public static string GetDefinedGenerateIfCondition(this ISymbol symbol) - { - var attrs = symbol.GetAttributes(); - if (attrs.FindAttributeShortName("GenerateDefineDebugAttribute") != null) - { - return "DEBUG"; - } - - var defineIfAttr = attrs.FindAttributeShortName("GenerateIfDirectiveAttribute"); - if (defineIfAttr != null) - { - return defineIfAttr.ConstructorArguments[0].Value?.ToString() ?? string.Empty; - } - - return string.Empty; - } } diff --git a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Abstractions/GenerateDefineDebugAttribute.cs b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Abstractions/GenerateDefineDebugAttribute.cs index e65cbe23b..1965ea622 100644 --- a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Abstractions/GenerateDefineDebugAttribute.cs +++ b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Abstractions/GenerateDefineDebugAttribute.cs @@ -10,6 +10,7 @@ namespace MagicOnion /// instruction for moc.exe, surround #if symbol with output code. /// [AttributeUsage(AttributeTargets.Method | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)] + [Obsolete("GenerateDefineDebug is no longer used from the generator. Use C# '#if' directive instead.")] public class GenerateDefineDebugAttribute : Attribute { public GenerateDefineDebugAttribute() diff --git a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Abstractions/GenerateIfDirectiveAttribute.cs b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Abstractions/GenerateIfDirectiveAttribute.cs index 8739ebb93..fd50cd6fa 100644 --- a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Abstractions/GenerateIfDirectiveAttribute.cs +++ b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Abstractions/GenerateIfDirectiveAttribute.cs @@ -6,10 +6,11 @@ namespace MagicOnion /// instruction for moc.exe, surround #if symbol with output code. /// [AttributeUsage(AttributeTargets.Method | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)] + [Obsolete("GenerateIfDirective is no longer used from the generator. Use C# '#if' directive instead.")] public class GenerateIfDirectiveAttribute : Attribute { public GenerateIfDirectiveAttribute(string condition) { } } -} \ No newline at end of file +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs index 14dcf532a..b99a5b815 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Collector/SerializationInfoCollectorTest.cs @@ -19,11 +19,9 @@ public void NonGenerics() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject"), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject"), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject"), new string[] { "CONST_2 || DEBUG"}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject"), new string[] { "CONST_3" }), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject"), + MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject"), }; // Act @@ -43,8 +41,8 @@ public void Nullable() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject")), new string[] { }), + MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), + MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject")), }; // Act @@ -59,35 +57,6 @@ public void Nullable() serializationInfoCollection.TypeHints.Should().HaveCount(4); // Non-nullable + Nullable } - [Fact] - public void Generics_MergeIfDirectives() - { - // Arrange - var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_2 || DEBUG"}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_3" }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().HaveCount(2); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.MyGenericObjectFormatter()"); - // NOTE: If there is a type without `if` condition, then merged if condition is always empty. (The type is always required by consumers) - serializationInfoCollection.Generics[0].IfDirectiveConditions.Should().BeEmpty(); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.YetAnotherGenericObjectFormatter()"); - serializationInfoCollection.Generics[1].IfDirectiveConditions.Should().HaveCount(2); - serializationInfoCollection.Generics[1].IfDirectiveConditions.Should().BeEquivalentTo("CONST_2 || DEBUG", "CONST_3"); - serializationInfoCollection.TypeHints.Should().HaveCount(4); // int, string, MyGenericObject, YetAnotherGenericObject - } - [Fact] public void Generics_ManyTypeArguments() { @@ -95,8 +64,8 @@ public void Generics_ManyTypeArguments() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), + MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), + MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), }; // Act @@ -117,11 +86,11 @@ public void Enum() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnumConditional", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType())), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnumConditional", MagicOnionTypeInfo.CreateFromType())), new string[] { "CONST_2" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "YetAnotherEnum", MagicOnionTypeInfo.CreateFromType())), new string[] { }), + MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType()), + MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnumConditional", MagicOnionTypeInfo.CreateFromType()), + MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType())), + MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnumConditional", MagicOnionTypeInfo.CreateFromType())), + MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "YetAnotherEnum", MagicOnionTypeInfo.CreateFromType())), }; // Act @@ -134,15 +103,12 @@ public void Enum() serializationInfoCollection.Enums[0].Namespace.Should().Be("MyNamespace"); serializationInfoCollection.Enums[0].Name.Should().Be("MyEnum"); serializationInfoCollection.Enums[0].GetFormatterNameWithConstructorArgs().Should().Be("MyEnumFormatter()"); - serializationInfoCollection.Enums[0].HasIfDirectiveConditions.Should().BeFalse(); serializationInfoCollection.Enums[1].Namespace.Should().Be("MyNamespace"); serializationInfoCollection.Enums[1].Name.Should().Be("MyEnumConditional"); serializationInfoCollection.Enums[1].GetFormatterNameWithConstructorArgs().Should().Be("MyEnumConditionalFormatter()"); - serializationInfoCollection.Enums[1].IfDirectiveConditions.Should().BeEquivalentTo("CONST_1", "CONST_2"); serializationInfoCollection.Enums[2].Namespace.Should().Be("MyNamespace"); serializationInfoCollection.Enums[2].Name.Should().Be("YetAnotherEnum"); serializationInfoCollection.Enums[2].GetFormatterNameWithConstructorArgs().Should().Be("YetAnotherEnumFormatter()"); - serializationInfoCollection.Enums[2].HasIfDirectiveConditions.Should().BeFalse(); serializationInfoCollection.TypeHints.Should().HaveCount(6); // MyEnum, MyEnumConditional, YetAnotherEnum, MyGenericObject, MyGenericObject, MyGenericObject } @@ -153,8 +119,8 @@ public void KnownTypes_SkipBuiltInGenericTypes() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType?>(), new string[] {}), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType?>(), }; // Act @@ -173,29 +139,29 @@ public void KnownTypes_Array_SkipBuiltInTypes() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MessagePack", "Nil")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector2")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector3")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector4")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Quaternion")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Color")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Bounds")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Rect")), new string[] {}), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MessagePack", "Nil")), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector2")), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector3")), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector4")), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Quaternion")), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Color")), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Bounds")), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Rect")), }; // Act @@ -214,10 +180,10 @@ public void KnownTypes_Array_NonBuiltIn() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 2), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 3), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 4), new string[] { "CONST_1" }), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 2), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 3), + MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 4), }; // Act @@ -240,18 +206,18 @@ public void KnownTypes_Generics() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "List",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IList",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyList",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "Dictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IDictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyDictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "ICollection",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyCollection",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IEnumerable",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "KeyValuePair",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Linq", "ILookup",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Linq", "IGrouping",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), + MagicOnionTypeInfo.Create("System.Collections.Generic", "List",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Collections.Generic", "IList",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyList",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Collections.Generic", "Dictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Collections.Generic", "IDictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyDictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Collections.Generic", "ICollection",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyCollection",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Collections.Generic", "IEnumerable",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Collections.Generic", "KeyValuePair",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Linq", "ILookup",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), + MagicOnionTypeInfo.Create("System.Linq", "IGrouping",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), }; // Act @@ -282,19 +248,19 @@ public void KnownTypes_Nullable() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), + MagicOnionTypeInfo.CreateFromType(), }; // Act @@ -314,14 +280,14 @@ public void KnownTypes_ValueTuple() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), }; // Act @@ -348,14 +314,14 @@ public void KnownTypes_Tuple() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), + MagicOnionTypeInfo.CreateFromType>(), }; // Act @@ -381,8 +347,8 @@ public void DynamicArgumentTuple() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), + MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), + MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), }; // Act @@ -404,9 +370,9 @@ public void UserDefinedMessagePackSerializerFormattersNamespace() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(userDefinedMessagePackFormattersNamespace)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { }), + MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), + MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), + MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), }; // Act @@ -428,9 +394,9 @@ public void UserDefinedMessagePackSerializerFormattersNamespace_NotSpecified() var collector = new SerializationInfoCollector(new MessagePackFormatterNameMapper(string.Empty)); var types = new[] { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { }), + MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), + MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), + MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), }; // Act From 7a8ee0a7398019b55240889cd07fee0da3cc3115 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 16:44:09 +0900 Subject: [PATCH 19/66] Remove legacy generator projects --- .../MagicOnion.Generator.csproj | 29 - src/MagicOnion.Generator/Program.cs | 38 - .../Properties/launchSettings.json | 8 - .../MagicOnion.GeneratorCore.csproj | 31 - .../Collector/MagicOnionTypeInfoTest.cs | 743 -------- .../Collector/MethodCollectorServicesTest.cs | 981 ---------- .../MethodCollectorStreamingHubsTest.cs | 781 -------- .../SerializationInfoCollectorTest.cs | 453 ----- .../CompilationHelper.cs | 34 - .../GenerateEnumFormatterTest.cs | 217 --- .../GenerateGenericsStreamingHubTest.cs | 1602 ----------------- .../GenerateGenericsTest.cs | 1028 ----------- .../GenerateRawStreamingTest.cs | 49 - .../GenerateServiceTest.cs | 324 ---- .../GenerateStreamingHub.cs | 534 ------ .../GenerateTest.cs | 436 ----- .../GenerateWithIfDirectiveTest.cs | 476 ----- .../MagicOnionGeneratorTestOutputLogger.cs | 22 - .../TemporaryProjectWorkarea.cs | 234 --- tests/MagicOnion.Generator.Tests/Usings.cs | 5 - 20 files changed, 8025 deletions(-) delete mode 100644 src/MagicOnion.Generator/MagicOnion.Generator.csproj delete mode 100644 src/MagicOnion.Generator/Program.cs delete mode 100644 src/MagicOnion.Generator/Properties/launchSettings.json delete mode 100644 src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj delete mode 100644 tests/MagicOnion.Generator.Tests/Collector/MagicOnionTypeInfoTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/Collector/MethodCollectorServicesTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/Collector/MethodCollectorStreamingHubsTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/Collector/SerializationInfoCollectorTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/CompilationHelper.cs delete mode 100644 tests/MagicOnion.Generator.Tests/GenerateEnumFormatterTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/GenerateGenericsStreamingHubTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/GenerateGenericsTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/GenerateRawStreamingTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/GenerateServiceTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/GenerateStreamingHub.cs delete mode 100644 tests/MagicOnion.Generator.Tests/GenerateTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/GenerateWithIfDirectiveTest.cs delete mode 100644 tests/MagicOnion.Generator.Tests/MagicOnionGeneratorTestOutputLogger.cs delete mode 100644 tests/MagicOnion.Generator.Tests/TemporaryProjectWorkarea.cs delete mode 100644 tests/MagicOnion.Generator.Tests/Usings.cs diff --git a/src/MagicOnion.Generator/MagicOnion.Generator.csproj b/src/MagicOnion.Generator/MagicOnion.Generator.csproj deleted file mode 100644 index 7f9c40ccd..000000000 --- a/src/MagicOnion.Generator/MagicOnion.Generator.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - Exe - net6.0;net7.0 - latest - moc - true - true - dotnet-moc - - - MagicOnion.Generator - MagicOnion standalone code generator. - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/MagicOnion.Generator/Program.cs b/src/MagicOnion.Generator/Program.cs deleted file mode 100644 index 9b204bfa6..000000000 --- a/src/MagicOnion.Generator/Program.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Threading.Tasks; -using ConsoleAppFramework; -using MagicOnion.Generator.Internal; - -namespace MagicOnion.Generator; - -public class Program -{ - static Task Main(string[] args) - => ConsoleApp.Create(args) - .AddRootCommand(RunAsync) - .RunAsync(); - - [Command("", description: "MagicOnion Code Generator generates client codes for Ahead-of-Time compilation.")] - static async Task RunAsync( - ConsoleAppContext ctx, - [Option("i", "The path to the project (.csproj) to generate the client.")]string input, - [Option("o", "The generated file path (single file) or the directory path to generate the files (multiple files).")]string output, - [Option("u", "Do not use UnityEngine's RuntimeInitializeOnLoadMethodAttribute on MagicOnionInitializer. (Same as --disable-auto-register)")]bool noUseUnityAttr = false, - [Option("d", "Do not automatically call MagicOnionInitializer during start-up. (Automatic registration requires .NET 5+ or Unity)")]bool disableAutoRegister = false, - [Option("n", "The namespace of clients to generate.")]string @namespace = "MagicOnion", - [Option("m", "The namespace of pre-generated MessagePackFormatters.")]string messagepackFormatterNamespace = "MessagePack.Formatters", - [Option("c", "The conditional compiler symbols used during code analysis. The value is split by ','.")]string conditionalSymbol = null, - [Option("v", "Enable verbose logging")]bool verbose = false, - [Option("s", "The serializer used for message serialization")] SerializerType serializer = SerializerType.MessagePack - ) - { - await new MagicOnionCompiler(new MagicOnionGeneratorConsoleLogger(verbose), ctx.CancellationToken) - .GenerateFileAsync( - input, - output, - disableAutoRegister, - @namespace, - conditionalSymbol, - messagepackFormatterNamespace, - serializer); - } -} diff --git a/src/MagicOnion.Generator/Properties/launchSettings.json b/src/MagicOnion.Generator/Properties/launchSettings.json deleted file mode 100644 index 43ae30050..000000000 --- a/src/MagicOnion.Generator/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "MagicOnion.Generator": { - "commandName": "Project", - "commandLineArgs": "-c \"NON_UNITY\" -i \"C:\\GitHubRepositories\\MagicOnion\\sandbox\\Sandbox.NetCoreServer\\Sandbox.NetCoreServer.csproj\" -o \"C:\\GitHubRepositories\\MagicOnion\\sandbox\\Sandbox.NetCoreServer\\MagicOnionGenerated.cs\"" - } - } -} \ No newline at end of file diff --git a/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj b/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj deleted file mode 100644 index ecdf3e575..000000000 --- a/src/MagicOnion.GeneratorCore/MagicOnion.GeneratorCore.csproj +++ /dev/null @@ -1,31 +0,0 @@ - - - - netstandard2.0 - MagicOnion.Generator - latestMajor - enable - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/MagicOnion.Generator.Tests/Collector/MagicOnionTypeInfoTest.cs b/tests/MagicOnion.Generator.Tests/Collector/MagicOnionTypeInfoTest.cs deleted file mode 100644 index b21280ca8..000000000 --- a/tests/MagicOnion.Generator.Tests/Collector/MagicOnionTypeInfoTest.cs +++ /dev/null @@ -1,743 +0,0 @@ -using MagicOnion.Generator.CodeAnalysis; -using Microsoft.CodeAnalysis; - -namespace MagicOnion.Generator.Tests.Collector; - -public class MagicOnionTypeInfoTest -{ - [Fact] - public void Simple() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.Create("System", "String"); - - // Assert - var fullName = typeInfo.FullName; - fullName.Should().Be("global::System.String"); - typeInfo.IsArray.Should().BeFalse(); - typeInfo.IsEnum.Should().BeFalse(); - typeInfo.ElementType.Should().BeNull(); - typeInfo.UnderlyingType.Should().BeNull(); - } - - [Fact] - public void CreateArray() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateArray("System", "String"); - - // Assert - var fullName = typeInfo.FullName; - fullName.Should().Be("global::System.String[]"); - typeInfo.IsArray.Should().BeTrue(); - typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.Create("System", "String")); - } - - [Fact] - public void CreateArray_Generics() - { - // Arrange & Act - // Tuple[] - var typeInfo = MagicOnionTypeInfo.CreateArray("System", "Tuple", - MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.CreateValueType("System", "Int32")), MagicOnionTypeInfo.Create("System", "String")); - - // Assert - var fullName = typeInfo.FullName; - fullName.Should().Be("global::System.Tuple[]"); - typeInfo.IsArray.Should().BeTrue(); - } - - [Fact] - public void CreateArray_JaggedArray() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("System", "String[]")); - - // Assert - var fullName = typeInfo.FullName; - fullName.Should().Be("global::System.String[][]"); - typeInfo.IsArray.Should().BeTrue(); - typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.Create("System", "String[]")); // NOTE: Currently, MOTypeInfo doesn't handle an element type for jagged array. - } - - [Fact] - public void CreateArray_Rank() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("System", "String"), 3); - - // Assert - var fullName = typeInfo.FullName; - fullName.Should().Be("global::System.String[,,]"); - typeInfo.ArrayRank.Should().Be(3); - typeInfo.IsArray.Should().BeTrue(); - } - - [Fact] - public void CreateFromType() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - - // Assert - typeInfo.FullName.Should().Be("global::System.String"); - typeInfo.IsEnum.Should().BeFalse(); - typeInfo.IsArray.Should().BeFalse(); - typeInfo.IsValueType.Should().BeFalse(); - } - - [Fact] - public void CreateFromType_ValueType() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - - // Assert - typeInfo.FullName.Should().Be("global::System.Byte"); - typeInfo.IsEnum.Should().BeFalse(); - typeInfo.IsArray.Should().BeFalse(); - typeInfo.IsValueType.Should().BeTrue(); - } - - [Fact] - public void CreateFromType_Generics() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateFromType>(); - - // Assert - typeInfo.FullName.Should().Be("global::System.Tuple"); - typeInfo.GenericArguments.Should().HaveCount(2); - typeInfo.IsEnum.Should().BeFalse(); - typeInfo.IsArray.Should().BeFalse(); - } - - [Fact] - public void CreateFromType_Array() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - - // Assert - typeInfo.FullName.Should().Be("global::System.Int32[]"); - typeInfo.GenericArguments.Should().BeEmpty(); - typeInfo.IsEnum.Should().BeFalse(); - typeInfo.IsArray.Should().BeTrue(); - typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.CreateValueType("System", "Int32")); - typeInfo.ArrayRank.Should().Be(1); - } - - [Fact] - public void CreateFromType_Array_Rank() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - - // Assert - typeInfo.FullName.Should().Be("global::System.Int32[,,]"); - typeInfo.GenericArguments.Should().BeEmpty(); - typeInfo.IsEnum.Should().BeFalse(); - typeInfo.IsArray.Should().BeTrue(); - typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.CreateValueType("System", "Int32")); - typeInfo.ArrayRank.Should().Be(3); - } - - [Fact] - public void CreateFromType_Enum() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - - // Assert - typeInfo.FullName.Should().Be("global::System.DayOfWeek"); - typeInfo.GenericArguments.Should().BeEmpty(); - typeInfo.IsEnum.Should().BeTrue(); - typeInfo.IsValueType.Should().BeTrue(); - typeInfo.UnderlyingType.Should().Be(MagicOnionTypeInfo.CreateValueType("System", "Int32")); - typeInfo.IsArray.Should().BeFalse(); - typeInfo.ElementType.Should().BeNull(); - } - - [Fact] - public void CreateFromType_Enum_Array() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - - // Assert - typeInfo.FullName.Should().Be("global::System.DayOfWeek[]"); - typeInfo.GenericArguments.Should().BeEmpty(); - typeInfo.IsEnum.Should().BeFalse(); - typeInfo.UnderlyingType.Should().BeNull(); - typeInfo.IsArray.Should().BeTrue(); - typeInfo.ElementType.Should().Be(MagicOnionTypeInfo.CreateEnum("System", "DayOfWeek", MagicOnionTypeInfo.CreateValueType("System", "Int32"))); - typeInfo.ElementType.IsEnum.Should().BeTrue(); - typeInfo.ElementType.IsArray.Should().BeFalse(); - typeInfo.ElementType.IsValueType.Should().BeTrue(); - typeInfo.ElementType.UnderlyingType.Should().Be(MagicOnionTypeInfo.CreateValueType("System", "Int32")); - } - - [Fact] - public void CreateValueType() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateValueType("MyNamespace", "MyStruct", new [] { MagicOnionTypeInfo.CreateFromType() }); - - // Assert - typeInfo.IsValueType.Should().BeTrue(); - } - - [Fact] - public void CreateEnum() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType()); - } - - [Fact] - public void WithGenericArgument() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.Create("System.Collections.Generic", "Dictionary", - MagicOnionTypeInfo.Create("System", "String"), - MagicOnionTypeInfo.CreateValueType("System", "Int32")); - - // Assert - var fullName = typeInfo.FullName; - var genericArguments = typeInfo.GenericArguments; - fullName.Should().Be("global::System.Collections.Generic.Dictionary"); - genericArguments.Should().BeEquivalentTo(MagicOnionTypeInfo.Create("System", "String"), MagicOnionTypeInfo.CreateValueType("System", "Int32")); - } - - [Fact] - public void WithGenericArgumentNested() - { - // Arrange & Act - var typeInfo = MagicOnionTypeInfo.Create("System.Collections.Generic", "Dictionary", - MagicOnionTypeInfo.Create("System", "String"), - MagicOnionTypeInfo.Create("System", "Tuple", - MagicOnionTypeInfo.CreateValueType("System", "Double"), - MagicOnionTypeInfo.CreateValueType("System", "Byte"))); - - // Assert - var fullName = typeInfo.FullName; - var genericArgumentsNested = typeInfo.GenericArguments[1].GenericArguments; - fullName.Should().Be("global::System.Collections.Generic.Dictionary>"); - genericArgumentsNested.Should().BeEquivalentTo(MagicOnionTypeInfo.CreateValueType("System", "Double"), MagicOnionTypeInfo.CreateValueType("System", "Byte")); - } - - [Fact] - public void FromSymbol_Global() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - public class MyClass { } - "); - var symbols = compilation.GlobalNamespace.GetTypeMembers("MyClass"); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0]); - - // Assert - typeInfo.Namespace.Should().BeEmpty(); - typeInfo.Name.Should().Be("MyClass"); - typeInfo.FullName.Should().Be("global::MyClass"); - } - - [Fact] - public void FromSymbol_Namespaced() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public class MyClass { } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "MyClass", SymbolFilter.Type).OfType().ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0]); - - // Assert - typeInfo.Namespace.Should().Be("MyNamespace"); - typeInfo.Name.Should().Be("MyClass"); - typeInfo.FullName.Should().Be("global::MyNamespace.MyClass"); - } - - [Fact] - public void FromSymbol_Nullable() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public class MyClass - { - public System.Tuple FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Should().Be(MagicOnionTypeInfo.Create("System", "Tuple", - MagicOnionTypeInfo.CreateValueType("System", "Nullable", - MagicOnionTypeInfo.CreateValueType("System", "Boolean")), - MagicOnionTypeInfo.CreateValueType("System", "Nullable", - MagicOnionTypeInfo.CreateValueType("System", "Int64")))); - } - - [Fact] - public void FromSymbol_ValueType() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public class MyClass - { - public int FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Should().Be(MagicOnionTypeInfo.CreateValueType( "System", "Int32", Array.Empty())); - typeInfo.IsValueType.Should().BeTrue(); - typeInfo.IsEnum.Should().BeFalse(); - } - - [Fact] - public void FromSymbol_Enum() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public enum MyEnum : byte - { - A, B, C - } - public class MyClass - { - public MyEnum FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Should().Be(MagicOnionTypeInfo.CreateEnum( "MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateValueType("System", "Byte"))); - } - - [Fact] - public void FromSymbol_Enum_Array() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public enum MyEnum : byte - { - A, B, C - } - public class MyClass - { - public MyEnum[] FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Should().Be(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.CreateEnum( "MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateValueType("System", "Byte")))); - } - - [Fact] - public void FromSymbol_Enum_Generics() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public enum MyEnum : byte - { - A, B, C - } - public class MyClass - { - public System.Tuple FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Should().Be(MagicOnionTypeInfo.Create("System", "Tuple", - MagicOnionTypeInfo.CreateValueType("System", "Int32"), - MagicOnionTypeInfo.CreateEnum( "MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateValueType("System", "Byte")))); - } - - [Fact] - public void FromSymbol_Array() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public class MyClass - { - public int[] FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Should().Be(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.CreateValueType("System", "Int32"))); - } - - [Fact] - public void FromSymbol_JaggedArray() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public class MyClass - { - public int[][] FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Should().Be(MagicOnionTypeInfo.CreateArray("System", "Int32[]")); - } - - [Fact] - public void FromSymbol_ArrayGenerics() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public class MyClass - { - public System.Tuple[] FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Should().Be(MagicOnionTypeInfo.CreateArray("System", "Tuple", - MagicOnionTypeInfo.CreateValueType("System", "Int32"), - MagicOnionTypeInfo.Create("System", "String"))); - } - - [Fact] - public void FromSymbol_ArrayRank() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public class MyClass - { - public string[,,] FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Should().Be(MagicOnionTypeInfo.CreateArray("System", "String", Array.Empty(), 3)); - } - - [Fact] - public void FromSymbol_Generics() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - public class MyClass - { - public System.Collections.Generic.List FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Namespace.Should().Be("System.Collections.Generic"); - typeInfo.Name.Should().Be("List"); - typeInfo.GenericArguments.Should().HaveCount(1); - typeInfo.GenericArguments[0].Should().Be(MagicOnionTypeInfo.Create("System", "String")); - typeInfo.FullName.Should().Be("global::System.Collections.Generic.List"); - } - - [Fact] - public void FromSymbol_Generics_Nested() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - using System; - using System.Collections.Generic; - public class MyClass - { - public List> FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Namespace.Should().Be("System.Collections.Generic"); - typeInfo.Name.Should().Be("List"); - typeInfo.GenericArguments.Should().HaveCount(1); - typeInfo.GenericArguments[0].Should().Be(MagicOnionTypeInfo.Create("System", "Tuple", MagicOnionTypeInfo.CreateValueType("System", "Int32"), MagicOnionTypeInfo.Create("System", "String"))); - typeInfo.FullName.Should().Be("global::System.Collections.Generic.List>"); - } - - [Fact] - public void FromSymbol_NamedValueTuple() - { - // Arrange - var (compilation, semModel) = CompilationHelper.Create(@" - namespace MyNamespace - { - using System; - using System.Collections.Generic; - public class MyClass - { - public (string Name, int Age) FieldA; - } - } - "); - var symbols = compilation.GetSymbolsWithName(x => x == "FieldA", SymbolFilter.Member) - .OfType() - .ToArray(); - - // Act - var typeInfo = MagicOnionTypeInfo.CreateFromSymbol(symbols[0].Type); - - // Assert - typeInfo.Namespace.Should().Be("System"); - typeInfo.Name.Should().Be("ValueTuple"); - typeInfo.GenericArguments.Should().HaveCount(2); - typeInfo.GenericArguments[0].Should().Be(MagicOnionTypeInfo.Create("System", "String")); - typeInfo.GenericArguments[1].Should().Be(MagicOnionTypeInfo.CreateValueType("System", "Int32")); - typeInfo.FullName.Should().Be("global::System.ValueTuple"); - } - - [Fact] - public void ToDisplay_Short() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - // Act - var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Short); - // Assert - formatted.Should().Be("Nil"); - } - - [Fact] - public void ToDisplay_Short_Nested() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType>(); - // Act - var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Short); - // Assert - formatted.Should().Be("Tuple"); - } - - [Fact] - public void ToDisplay_FullyQualified() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - // Act - var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.FullyQualified); - // Assert - formatted.Should().Be("global::MessagePack.Nil"); - } - - [Fact] - public void ToDisplay_FullyQualified_Nested() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType>(); - // Act - var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.FullyQualified); - // Assert - formatted.Should().Be("global::System.Tuple"); - } - - [Fact] - public void ToDisplay_Namespace() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - // Act - var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace); - // Assert - formatted.Should().Be("MessagePack.Nil"); - } - - [Fact] - public void ToDisplay_OpenGenerics() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType>(); - // Act - var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.OpenGenerics); - // Assert - formatted.Should().Be("Tuple<,>"); - } - - [Fact] - public void ToDisplay_WithoutGenericArguments() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType>(); - // Act - var formatted = typeInfo.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.WithoutGenericArguments); - // Assert - formatted.Should().Be("Tuple"); - } - - [Fact] - public void EnumerateDependentTypes_Array() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - // Act - var types = typeInfo.EnumerateDependentTypes().ToArray(); - // Assert - types.Should().BeEquivalentTo(MagicOnionTypeInfo.CreateFromType()); - } - - [Fact] - public void EnumerateDependentTypes_Enum_Array() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType(); - // Act - var types = typeInfo.EnumerateDependentTypes().ToArray(); - // Assert - types.Should().BeEquivalentTo(MagicOnionTypeInfo.CreateFromType()); - } - - [Fact] - public void EnumerateDependentTypes_Enum_Generics() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType>(); - // Act - var types = typeInfo.EnumerateDependentTypes().ToArray(); - // Assert - types.Should().BeEquivalentTo(MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()); - } - - [Fact] - public void EnumerateDependentTypes_Generics() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType>(); - // Act - var types = typeInfo.EnumerateDependentTypes().ToArray(); - // Assert - types.Should().BeEquivalentTo(MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()); - } - - [Fact] - public void EnumerateDependentTypes_Generics_Nested() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType>>>(); - // Act - var types = typeInfo.EnumerateDependentTypes().ToArray(); - // Assert - types.Should().BeEquivalentTo( - MagicOnionTypeInfo.CreateFromType(), - MagicOnionTypeInfo.CreateFromType>>(), - MagicOnionTypeInfo.CreateFromType(), - MagicOnionTypeInfo.CreateFromType>(), - MagicOnionTypeInfo.CreateFromType(), - MagicOnionTypeInfo.CreateFromType()); - } - - [Fact] - public void GetGenericTypeDefinition() - { - // Arrange - var typeInfo = MagicOnionTypeInfo.CreateFromType>(); - // Act - var genericDefinition = typeInfo.GetGenericTypeDefinition(); - // Assert - genericDefinition.Should().Be(MagicOnionTypeInfo.Create("System", "ValueTuple", Array.Empty(), true)); - } -} diff --git a/tests/MagicOnion.Generator.Tests/Collector/MethodCollectorServicesTest.cs b/tests/MagicOnion.Generator.Tests/Collector/MethodCollectorServicesTest.cs deleted file mode 100644 index 455230778..000000000 --- a/tests/MagicOnion.Generator.Tests/Collector/MethodCollectorServicesTest.cs +++ /dev/null @@ -1,981 +0,0 @@ -using MagicOnion.Generator.CodeAnalysis; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests.Collector; - -public class MethodCollectorServicesTest -{ - readonly ITestOutputHelper testOutputHelper; - - public MethodCollectorServicesTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public void FileScopedNamespace() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - UnaryResult NilAsync(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(1); - // UnaryResult NilAsync(); - serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("NilAsync"); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - } - - [Fact] - public void IfDirectives() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -[GenerateIfDirective(""DEBUG || CONST_1 || CONST_2"")] -public interface IMyService : IService -{ - [GenerateDefineDebug] - UnaryResult MethodA(); - - [GenerateIfDirective(""CONST_3"")] - UnaryResult MethodB(); - - UnaryResult MethodC(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeTrue(); - serviceCollection.Services[0].IfDirectiveCondition.Should().Be("DEBUG || CONST_1 || CONST_2"); - serviceCollection.Services[0].Methods[0].HasIfDirectiveCondition.Should().BeTrue(); - serviceCollection.Services[0].Methods[0].IfDirectiveCondition.Should().Be("DEBUG"); - serviceCollection.Services[0].Methods[1].HasIfDirectiveCondition.Should().BeTrue(); - serviceCollection.Services[0].Methods[1].IfDirectiveCondition.Should().Be("CONST_3"); - serviceCollection.Services[0].Methods[2].HasIfDirectiveCondition.Should().BeFalse(); - } - - [Fact] - public void Ignore_Method() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - UnaryResult MethodA(); - - [Ignore] - UnaryResult MethodB(); - - UnaryResult MethodC(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].Methods.Should().HaveCount(2); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Services[0].Methods[1].MethodName.Should().Be("MethodC"); - } - - [Fact] - public void Ignore_Interface() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -[Ignore] -public interface IMyService : IService -{ - UnaryResult MethodA(); - - UnaryResult MethodB(); - - UnaryResult MethodC(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().BeEmpty(); - } - - [Fact] - public void Unary_NonGenericResult() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult MethodA(); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - } - - [Fact] - public void Unary_Array() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult[]> MethodA(Tuple[] arg1); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType[]>()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType[]>()); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType[]>>()); - } - - [Fact] - public void Unary_Nullable() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult MethodA(Tuple arg1); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - } - - [Fact] - public void Unary_Parameter_Zero_ReturnNil() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult MethodA(); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(1); - // UnaryResult MethodA(); - serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - } - - - [Fact] - public void Unary_Parameter_Zero_ReturnValue() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult MethodA(); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(1); - // UnaryResult MethodA(); - serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - } - - [Fact] - public void Unary_Parameter_One_ReturnNil() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult MethodA(string arg1); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(1); - // UnaryResult MethodA(string arg1); - serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - } - - [Fact] - public void Unary_Parameter_Many_ReturnNil() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult MethodA(string arg1, int arg2); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(1); - // UnaryResult MethodA(string arg1, int arg2); - serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[1].Type.Should().Be( MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - } - - - [Fact] - public void Unary_HasDefaultValue() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult MethodA(string arg1 = ""Hello"", int arg2 = 1234, long arg3 = default, string arg4 = default); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Services[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[0].HasExplicitDefaultValue.Should().BeTrue(); - serviceCollection.Services[0].Methods[0].Parameters[0].DefaultValue.Should().Be("\"Hello\""); - serviceCollection.Services[0].Methods[0].Parameters[1].Type.Should().Be( MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[1].DefaultValue.Should().Be("1234"); - serviceCollection.Services[0].Methods[0].Parameters[1].HasExplicitDefaultValue.Should().BeTrue(); - serviceCollection.Services[0].Methods[0].Parameters[2].Type.Should().Be( MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[2].DefaultValue.Should().Be("0"); - serviceCollection.Services[0].Methods[0].Parameters[2].HasExplicitDefaultValue.Should().BeTrue(); - serviceCollection.Services[0].Methods[0].Parameters[3].Type.Should().Be( MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[3].DefaultValue.Should().Be("null"); - serviceCollection.Services[0].Methods[0].Parameters[3].HasExplicitDefaultValue.Should().BeTrue(); - } - - [Fact] - public void Unary_Methods() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult NilAsync(); - UnaryResult StringAsync(); - UnaryResult OneParameter(string arg1); - UnaryResult TwoParameter(string arg1, int arg2); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(4); - } - - [Fact] - public void Unary_InvalidReturnType_ServerStreamingResult() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult> MethodA(); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act & Assert - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - Assert.Throws(() => collector.Collect(compilation)); - } - - [Fact] - public void Unary_InvalidReturnType_ClientStreamingResult() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult> MethodA(); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act & Assert - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - Assert.Throws(() => collector.Collect(compilation)); - } - - [Fact] - public void Unary_InvalidReturnType_DuplexStreamingResult() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - UnaryResult> MethodA(); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act & Assert - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - Assert.Throws(() => collector.Collect(compilation)); - } - - [Fact] - public void UnsupportedType() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace -{ - public interface IMyService : IService - { - void MethodA(); - } -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act & Assert - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - Assert.Throws(() => collector.Collect(compilation)); - } - - [Fact] - public void ServerStreaming_Parameter_Zero() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - Task> ServerStreaming(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(1); - // Task> ServerStreamingNoArg(); - serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("ServerStreaming"); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>>()); - } - - [Fact] - public void ServerStreaming_Parameter_One() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - Task> ServerStreaming(string arg1); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(1); - // Task> ServerStreamingNoArg(); - serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("ServerStreaming"); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>>()); - } - - [Fact] - public void ServerStreaming_Parameter_Many() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - Task> ServerStreaming(string arg1, int arg2); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(1); - // Task> ServerStreamingNoArg(); - serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("ServerStreaming"); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); - serviceCollection.Services[0].Methods[0].Parameters[1].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters[1].Name.Should().Be("arg2"); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>>()); - } - - [Fact] - public void ServerStreaming_ShouldNotBeTask() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - ServerStreamingResult ServerStreaming(string arg1, int arg2); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act & Assert - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - Assert.Throws(() => collector.Collect(compilation)); - } - - - [Fact] - public void DuplexStreaming() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - Task> MethodA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(1); - // Task> MethodA(); - serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>>()); - } - - [Fact] - public void DuplexStreaming_ParameterNotSupported() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - Task> MethodA(string arg1); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act & Assert - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - Assert.Throws(() => collector.Collect(compilation)); - } - - [Fact] - public void ClientStreaming() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - Task> MethodA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().HaveCount(1); - serviceCollection.Services[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyService")); - serviceCollection.Services[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Services[0].Methods.Should().HaveCount(1); - // Task> MethodA(); - serviceCollection.Services[0].Methods[0].ServiceName.Should().Be("IMyService"); - serviceCollection.Services[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Services[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Services[0].Methods[0].Parameters.Should().BeEmpty(); - serviceCollection.Services[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>>()); - } - - [Fact] - public void ClientStreaming_ParameterNotSupported() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - Task> MethodA(string arg1); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act & Assert - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - Assert.Throws(() => collector.Collect(compilation)); - } - - [Fact] - public void GlobalUsings() - { - // Arrange - var source = @" -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyService : IService -{ - UnaryResult NilAsync(); - UnaryResult StringAsync(); - UnaryResult OneParameter(string arg1); - UnaryResult TwoParameter(string arg1, int arg2); - Task> ServerStreaming(string arg1, int arg2); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(new TemporaryProjectWorkareaOptions() - { - TargetFramework = "netstandard2.0", - }); - tempWorkspace.AddFileToProject("Usings.cs", """ - global using System; - global using System.Threading.Tasks; - global using System.Collections.Generic; - """); - tempWorkspace.AddFileToProject("IMyService.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper)); - var serviceCollection = collector.Collect(compilation); - - // Assert - compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - serviceCollection.Should().NotBeNull(); - serviceCollection.Services.Should().NotBeEmpty(); - } -} diff --git a/tests/MagicOnion.Generator.Tests/Collector/MethodCollectorStreamingHubsTest.cs b/tests/MagicOnion.Generator.Tests/Collector/MethodCollectorStreamingHubsTest.cs deleted file mode 100644 index 232275d9d..000000000 --- a/tests/MagicOnion.Generator.Tests/Collector/MethodCollectorStreamingHubsTest.cs +++ /dev/null @@ -1,781 +0,0 @@ -using MagicOnion.Generator.CodeAnalysis; - -namespace MagicOnion.Generator.Tests.Collector; - -public class MethodCollectorStreamingHubsTest -{ - [Fact] - public void FileScopedNamespace() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().HaveCount(1); - serviceCollection.Services.Should().BeEmpty(); - serviceCollection.Hubs[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyHub")); - serviceCollection.Hubs[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Hubs[0].Methods.Should().HaveCount(1); - // Task MethodA(); - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Hubs[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Hubs[0].Methods[0].Parameters.Should().BeEmpty(); - serviceCollection.Hubs[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - } - - [Fact] - public void Ignore_Method() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(); - - [Ignore] - Task MethodB(); - - Task MethodC(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().HaveCount(1); - serviceCollection.Services.Should().BeEmpty(); - serviceCollection.Hubs[0].ServiceType.Should().Be(MagicOnionTypeInfo.Create("MyNamespace", "IMyHub")); - serviceCollection.Hubs[0].HasIfDirectiveCondition.Should().BeFalse(); - serviceCollection.Hubs[0].Methods.Should().HaveCount(2); - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[1].MethodName.Should().Be("MethodC"); - } - - [Fact] - public void Ignore_Interface() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -[Ignore] -public interface IMyHub : IStreamingHub -{ - Task MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().BeEmpty(); - serviceCollection.Services.Should().BeEmpty(); - serviceCollection.Hubs.Should().BeEmpty(); - } - - [Fact] - public void Parameter_Zero() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - // Task MethodA(); - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Hubs[0].Methods[0].Parameters.Should().BeEmpty(); - } - - [Fact] - public void Parameter_One() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(int arg1); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - // Task MethodA(); - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Hubs[0].Methods[0].Parameters.Should().HaveCount(1); - serviceCollection.Hubs[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); - serviceCollection.Hubs[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Hubs[0].Methods[0].Parameters[0].HasExplicitDefaultValue.Should().BeFalse(); - serviceCollection.Hubs[0].Methods[0].Parameters[0].DefaultValue.Should().Be("default(int)"); - } - - [Fact] - public void Parameter_Many() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(int arg1, string arg2); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - // Task MethodA(); - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - serviceCollection.Hubs[0].Methods[0].Parameters.Should().HaveCount(2); - serviceCollection.Hubs[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); - serviceCollection.Hubs[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Hubs[0].Methods[0].Parameters[0].HasExplicitDefaultValue.Should().BeFalse(); - serviceCollection.Hubs[0].Methods[0].Parameters[0].DefaultValue.Should().Be("default(int)"); - serviceCollection.Hubs[0].Methods[0].Parameters[1].Name.Should().Be("arg2"); - serviceCollection.Hubs[0].Methods[0].Parameters[1].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Hubs[0].Methods[0].Parameters[1].HasExplicitDefaultValue.Should().BeFalse(); - serviceCollection.Hubs[0].Methods[0].Parameters[1].DefaultValue.Should().Be("default(string)"); - } - - - [Fact] - public void Parameter_HasDefaultValue() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(int arg1, string arg2 = ""DEFAULT""); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - // Task MethodA(); - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - serviceCollection.Hubs[0].Methods[0].Parameters.Should().HaveCount(2); - serviceCollection.Hubs[0].Methods[0].Parameters[0].Name.Should().Be("arg1"); - serviceCollection.Hubs[0].Methods[0].Parameters[0].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Hubs[0].Methods[0].Parameters[0].HasExplicitDefaultValue.Should().BeFalse(); - serviceCollection.Hubs[0].Methods[0].Parameters[0].DefaultValue.Should().Be("default(int)"); - serviceCollection.Hubs[0].Methods[0].Parameters[1].Name.Should().Be("arg2"); - serviceCollection.Hubs[0].Methods[0].Parameters[1].Type.Should().Be(MagicOnionTypeInfo.CreateFromType()); - serviceCollection.Hubs[0].Methods[0].Parameters[1].HasExplicitDefaultValue.Should().BeTrue(); - serviceCollection.Hubs[0].Methods[0].Parameters[1].DefaultValue.Should().Be("\"DEFAULT\""); - } - - [Fact] - public void HubId_Implicit() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().HaveCount(1); - serviceCollection.Hubs[0].Methods.Should().HaveCount(1); - // Task MethodA(); - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].HubId.Should().Be(1497325507); - // void EventA(); - serviceCollection.Hubs[0].Receiver.Methods[0].MethodName.Should().Be("EventA"); - serviceCollection.Hubs[0].Receiver.Methods[0].HubId.Should().Be(842297178); - } - - [Fact] - public void HubId_Explicit() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -using MagicOnion.Server.Hubs; // for MethodIdAttribute - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - [MethodId(12345)] - Task MethodA(); -} - -public interface IMyHubReceiver -{ - [MethodId(67890)] - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().HaveCount(1); - serviceCollection.Hubs[0].Methods.Should().HaveCount(1); - // Task MethodA(); - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].HubId.Should().Be(12345); - // void EventA(); - serviceCollection.Hubs[0].Receiver.Methods[0].MethodName.Should().Be("EventA"); - serviceCollection.Hubs[0].Receiver.Methods[0].HubId.Should().Be(67890); - } - - [Fact] - public void ReturnType_NotSupported_Void() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - void MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act & Assert - var collector = new MethodCollector(); - var ex = Assert.Throws(() => collector.Collect(compilation)); - } - - [Fact] - public void ReturnType_NotSupported_NotTaskOfT() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - string MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act & Assert - var collector = new MethodCollector(); - var ex = Assert.Throws(() => collector.Collect(compilation)); - } - - [Fact] - public void ReturnType_Task() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); - serviceCollection.Hubs[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_Task); - } - - [Fact] - public void ReturnType_TaskOfT() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_String); - serviceCollection.Hubs[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - } - - [Fact] - public void ReturnType_ValueTask() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - ValueTask MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); - serviceCollection.Hubs[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_ValueTask); - } - - [Fact] - public void ReturnType_ValueTaskOfT() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - ValueTask MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Hubs[0].Methods[0].MethodName.Should().Be("MethodA"); - serviceCollection.Hubs[0].Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_String); - serviceCollection.Hubs[0].Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - } - - [Fact] - public void Receiver() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(); -} - -public interface IMyHubReceiver -{ - void EventA(); - void EventB(Nil nil); - void EventC(string arg1, int arg2); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Should().NotBeNull(); - serviceCollection.Hubs.Should().HaveCount(1); - serviceCollection.Hubs[0].Methods.Should().HaveCount(1); - serviceCollection.Hubs[0].Receiver.Should().NotBeNull(); - serviceCollection.Hubs[0].Receiver.Methods.Should().HaveCount(3); - // void EventA(); - serviceCollection.Hubs[0].Receiver.Methods[0].MethodName.Should().Be("EventA"); - serviceCollection.Hubs[0].Receiver.Methods[0].Parameters.Should().BeEmpty(); - serviceCollection.Hubs[0].Receiver.Methods[0].RequestType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); - serviceCollection.Hubs[0].Receiver.Methods[0].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); - serviceCollection.Hubs[0].Receiver.Methods[0].MethodReturnType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_Void); - // void EventB(Nil nil); - serviceCollection.Hubs[0].Receiver.Methods[1].MethodName.Should().Be("EventB"); - serviceCollection.Hubs[0].Receiver.Methods[1].Parameters.Should().HaveCount(1); - serviceCollection.Hubs[0].Receiver.Methods[1].RequestType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); - serviceCollection.Hubs[0].Receiver.Methods[1].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); - serviceCollection.Hubs[0].Receiver.Methods[1].MethodReturnType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_Void); - // void EventB(Nil nil); - serviceCollection.Hubs[0].Receiver.Methods[2].MethodName.Should().Be("EventC"); - serviceCollection.Hubs[0].Receiver.Methods[2].Parameters.Should().HaveCount(2); - serviceCollection.Hubs[0].Receiver.Methods[2].RequestType.Should().Be(MagicOnionTypeInfo.CreateFromType>()); - serviceCollection.Hubs[0].Receiver.Methods[2].ResponseType.Should().Be(MagicOnionTypeInfo.KnownTypes.MessagePack_Nil); - serviceCollection.Hubs[0].Receiver.Methods[2].MethodReturnType.Should().Be(MagicOnionTypeInfo.KnownTypes.System_Void); - } - - [Fact] - public void Receiver_NonVoidReturnType() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(); -} - -public interface IMyHubReceiver -{ - int EventA(); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act & Assert - var collector = new MethodCollector(); - var ex = Assert.Throws(() => collector.Collect(compilation)); - } - - [Fact] - public void IfDirectives() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -[GenerateIfDirective(""DEBUG || CONST_1 || CONST_2"")] -public interface IMyHub : IStreamingHub -{ - [GenerateDefineDebug] - Task MethodA(); - [GenerateIfDirective(""CONST_3"")] - Task MethodB(); - Task MethodC(); -} - -public interface IMyHubReceiver -{ - void EventA(); - void EventB(Nil nil); - void EventC(string arg1, int arg2); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Hubs[0].HasIfDirectiveCondition.Should().BeTrue(); - serviceCollection.Hubs[0].IfDirectiveCondition.Should().Be("DEBUG || CONST_1 || CONST_2"); - serviceCollection.Hubs[0].Methods[0].HasIfDirectiveCondition.Should().BeTrue(); - serviceCollection.Hubs[0].Methods[0].IfDirectiveCondition.Should().Be("DEBUG"); - serviceCollection.Hubs[0].Methods[1].HasIfDirectiveCondition.Should().BeTrue(); - serviceCollection.Hubs[0].Methods[1].IfDirectiveCondition.Should().Be("CONST_3"); - serviceCollection.Hubs[0].Methods[2].HasIfDirectiveCondition.Should().BeFalse(); - } - - [Fact] - public void IfDirectives_Receiver() - { - // Arrange - var source = @" -using System; -using System.Threading.Tasks; -using MagicOnion; -using MessagePack; - -namespace MyNamespace; - -public interface IMyHub : IStreamingHub -{ - Task MethodA(); - Task MethodB(); - Task MethodC(); -} - -[GenerateIfDirective(""DEBUG || CONST_1 || CONST_2"")] -public interface IMyHubReceiver -{ - [GenerateDefineDebug] - void EventA(); - [GenerateIfDirective(""CONST_3"")] - void EventB(Nil nil); - void EventC(string arg1, int arg2); -} -"; - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", source); - var compilation = tempWorkspace.GetOutputCompilation().Compilation; - - // Act - var collector = new MethodCollector(); - var serviceCollection = collector.Collect(compilation); - - // Assert - serviceCollection.Hubs[0].Receiver.HasIfDirectiveCondition.Should().BeTrue(); - serviceCollection.Hubs[0].Receiver.IfDirectiveCondition.Should().Be("DEBUG || CONST_1 || CONST_2"); - serviceCollection.Hubs[0].Receiver.Methods[0].HasIfDirectiveCondition.Should().BeTrue(); - serviceCollection.Hubs[0].Receiver.Methods[0].IfDirectiveCondition.Should().Be("DEBUG"); - serviceCollection.Hubs[0].Receiver.Methods[1].HasIfDirectiveCondition.Should().BeTrue(); - serviceCollection.Hubs[0].Receiver.Methods[1].IfDirectiveCondition.Should().Be("CONST_3"); - serviceCollection.Hubs[0].Receiver.Methods[2].HasIfDirectiveCondition.Should().BeFalse(); - } -} diff --git a/tests/MagicOnion.Generator.Tests/Collector/SerializationInfoCollectorTest.cs b/tests/MagicOnion.Generator.Tests/Collector/SerializationInfoCollectorTest.cs deleted file mode 100644 index ab85861be..000000000 --- a/tests/MagicOnion.Generator.Tests/Collector/SerializationInfoCollectorTest.cs +++ /dev/null @@ -1,453 +0,0 @@ -using MagicOnion.Generator.CodeAnalysis; -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests.Collector; - -public class SerializationInfoCollectorTest -{ - readonly ITestOutputHelper testOutputHelper; - - public SerializationInfoCollectorTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public void NonGenerics() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject"), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject"), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject"), new string[] { "CONST_2 || DEBUG"}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject"), new string[] { "CONST_3" }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Enums.Should().BeEmpty(); - serializationInfoCollection.Generics.Should().BeEmpty(); - serializationInfoCollection.TypeHints.Should().HaveCount(3); - } - - [Fact] - public void Nullable() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject")), new string[] { }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Enums.Should().BeEmpty(); - serializationInfoCollection.Generics.Should().HaveCount(2); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.NullableFormatter()"); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.NullableFormatter()"); - serializationInfoCollection.TypeHints.Should().HaveCount(4); // Non-nullable + Nullable - } - - [Fact] - public void Generics_MergeIfDirectives() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_2 || DEBUG"}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "YetAnotherGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_3" }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().HaveCount(2); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.MyGenericObjectFormatter()"); - // NOTE: If there is a type without `if` condition, then merged if condition is always empty. (The type is always required by consumers) - serializationInfoCollection.Generics[0].IfDirectiveConditions.Should().BeEmpty(); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.YetAnotherGenericObjectFormatter()"); - serializationInfoCollection.Generics[1].IfDirectiveConditions.Should().HaveCount(2); - serializationInfoCollection.Generics[1].IfDirectiveConditions.Should().BeEquivalentTo("CONST_2 || DEBUG", "CONST_3"); - serializationInfoCollection.TypeHints.Should().HaveCount(4); // int, string, MyGenericObject, YetAnotherGenericObject - } - - [Fact] - public void Generics_ManyTypeArguments() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().HaveCount(2); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.MyGenericObjectFormatter()"); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.MyGenericObjectFormatter()"); - serializationInfoCollection.TypeHints.Should().HaveCount(5); // string, int, long, MyGenericObject, MyGenericObject - } - - [Fact] - public void Enum() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnumConditional", MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnum", MagicOnionTypeInfo.CreateFromType())), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "MyEnumConditional", MagicOnionTypeInfo.CreateFromType())), new string[] { "CONST_2" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateEnum("MyNamespace", "YetAnotherEnum", MagicOnionTypeInfo.CreateFromType())), new string[] { }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().HaveCount(3); - serializationInfoCollection.Enums.Should().HaveCount(3); - serializationInfoCollection.Enums[0].Namespace.Should().Be("MyNamespace"); - serializationInfoCollection.Enums[0].Name.Should().Be("MyEnum"); - serializationInfoCollection.Enums[0].GetFormatterNameWithConstructorArgs().Should().Be("MyEnumFormatter()"); - serializationInfoCollection.Enums[0].HasIfDirectiveConditions.Should().BeFalse(); - serializationInfoCollection.Enums[1].Namespace.Should().Be("MyNamespace"); - serializationInfoCollection.Enums[1].Name.Should().Be("MyEnumConditional"); - serializationInfoCollection.Enums[1].GetFormatterNameWithConstructorArgs().Should().Be("MyEnumConditionalFormatter()"); - serializationInfoCollection.Enums[1].IfDirectiveConditions.Should().BeEquivalentTo("CONST_1", "CONST_2"); - serializationInfoCollection.Enums[2].Namespace.Should().Be("MyNamespace"); - serializationInfoCollection.Enums[2].Name.Should().Be("YetAnotherEnum"); - serializationInfoCollection.Enums[2].GetFormatterNameWithConstructorArgs().Should().Be("YetAnotherEnumFormatter()"); - serializationInfoCollection.Enums[2].HasIfDirectiveConditions.Should().BeFalse(); - serializationInfoCollection.TypeHints.Should().HaveCount(6); // MyEnum, MyEnumConditional, YetAnotherEnum, MyGenericObject, MyGenericObject, MyGenericObject - } - - [Fact] - public void KnownTypes_SkipBuiltInGenericTypes() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType?>(), new string[] {}), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().BeEmpty(); - serializationInfoCollection.TypeHints.Should().HaveCount(3); // byte, ArraySegment, Nullable> - } - - [Fact] - public void KnownTypes_Array_SkipBuiltInTypes() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MessagePack", "Nil")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector2")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector3")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Vector4")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Quaternion")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Color")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Bounds")), new string[] {}), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("UnityEngine", "Rect")), new string[] {}), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().BeEmpty(); - serializationInfoCollection.TypeHints.Should().HaveCount(46); - } - - [Fact] - public void KnownTypes_Array_NonBuiltIn() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 2), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 3), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateArray(MagicOnionTypeInfo.Create("MyNamespace", "MyObject"), arrayRank: 4), new string[] { "CONST_1" }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().HaveCount(4); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ArrayFormatter()"); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TwoDimensionalArrayFormatter()"); - serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ThreeDimensionalArrayFormatter()"); - serializationInfoCollection.Generics[3].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.FourDimensionalArrayFormatter()"); - serializationInfoCollection.TypeHints.Should().HaveCount(5); // MyObject, MyObject[], MyObject[,], MyObject[,,], MyObject[,,,] - } - - [Fact] - public void KnownTypes_Generics() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "List",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IList",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyList",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "Dictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IDictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyDictionary",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "ICollection",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IReadOnlyCollection",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "IEnumerable",MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Collections.Generic", "KeyValuePair",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Linq", "ILookup",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System.Linq", "IGrouping",MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.Create("MyNamespace", "MyObject")), new string[] { "CONST_1" }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().HaveCount(12); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ListFormatter()"); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceListFormatter2()"); - serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceReadOnlyListFormatter()"); - serializationInfoCollection.Generics[3].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.DictionaryFormatter()"); - serializationInfoCollection.Generics[4].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceDictionaryFormatter()"); - serializationInfoCollection.Generics[5].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter()"); - serializationInfoCollection.Generics[6].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceCollectionFormatter2()"); - serializationInfoCollection.Generics[7].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter()"); - serializationInfoCollection.Generics[8].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceEnumerableFormatter()"); - serializationInfoCollection.Generics[9].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.KeyValuePairFormatter()"); - serializationInfoCollection.Generics[10].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceLookupFormatter()"); - serializationInfoCollection.Generics[11].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.InterfaceGroupingFormatter()"); - serializationInfoCollection.TypeHints.Should().HaveCount(14); - } - - [Fact] - public void KnownTypes_Nullable() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType(), new string[] { }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Enums.Should().BeEmpty(); - serializationInfoCollection.Generics.Should().BeEmpty(); - serializationInfoCollection.TypeHints.Should().HaveCount(26); - } - - [Fact] - public void KnownTypes_ValueTuple() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().HaveCount(8); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); - serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); - serializationInfoCollection.Generics[3].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); - serializationInfoCollection.Generics[4].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); - serializationInfoCollection.Generics[5].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); - serializationInfoCollection.Generics[6].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); - serializationInfoCollection.Generics[7].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.ValueTupleFormatter()"); - serializationInfoCollection.TypeHints.Should().HaveCount(8 + 8); - } - - [Fact] - public void KnownTypes_Tuple() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.CreateFromType>(), new string[] { }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().HaveCount(8); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); - serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); - serializationInfoCollection.Generics[3].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); - serializationInfoCollection.Generics[4].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); - serializationInfoCollection.Generics[5].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); - serializationInfoCollection.Generics[6].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); - serializationInfoCollection.Generics[7].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.TupleFormatter()"); - } - - [Fact] - public void DynamicArgumentTuple() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { "CONST_1" }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Generics.Should().HaveCount(2); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int64))"); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32))"); - serializationInfoCollection.TypeHints.Should().HaveCount(5); // string, long, int, DynamicArgumentTuple, DynamicArgumentTuple - } - - [Fact] - public void UserDefinedMessagePackSerializerFormattersNamespace() - { - // Arrange - var userDefinedMessagePackFormattersNamespace = "MyFormatters"; - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(userDefinedMessagePackFormattersNamespace)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Enums.Should().BeEmpty(); - serializationInfoCollection.Generics.Should().HaveCount(3); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.NullableFormatter()"); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int64))"); - serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MyFormatters.MyNamespace.MyGenericObjectFormatter()"); - } - - [Fact] - public void UserDefinedMessagePackSerializerFormattersNamespace_NotSpecified() - { - // Arrange - var collector = new SerializationInfoCollector(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), new MessagePackFormatterNameMapper(string.Empty)); - var types = new[] - { - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("System", "Nullable", MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject")), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MagicOnion", "DynamicArgumentTuple", MagicOnionTypeInfo.CreateFromType(), MagicOnionTypeInfo.CreateFromType()), new string[] { }), - new SerializationInfoCollector.TypeWithIfDirectives(MagicOnionTypeInfo.Create("MyNamespace", "MyGenericObject", MagicOnionTypeInfo.CreateFromType()), new string[] { }), - }; - - // Act - var serializationInfoCollection = collector.Collect(types); - - // Assert - serializationInfoCollection.Should().NotBeNull(); - serializationInfoCollection.Enums.Should().BeEmpty(); - serializationInfoCollection.Generics.Should().HaveCount(3); - serializationInfoCollection.Generics[0].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.NullableFormatter()"); - serializationInfoCollection.Generics[1].GetFormatterNameWithConstructorArgs().Should().Be("global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int64))"); - serializationInfoCollection.Generics[2].GetFormatterNameWithConstructorArgs().Should().Be("global::MessagePack.Formatters.MyNamespace.MyGenericObjectFormatter()"); - } -} - -file static class SerializationFormatterRegisterInfoExtensions -{ - public static string GetFormatterNameWithConstructorArgs(this ISerializationFormatterRegisterInfo serializationFormatterRegisterInfo) - => serializationFormatterRegisterInfo.FormatterName + serializationFormatterRegisterInfo.FormatterConstructorArgs; -} diff --git a/tests/MagicOnion.Generator.Tests/CompilationHelper.cs b/tests/MagicOnion.Generator.Tests/CompilationHelper.cs deleted file mode 100644 index 90770f419..000000000 --- a/tests/MagicOnion.Generator.Tests/CompilationHelper.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; - -namespace MagicOnion.Generator.Tests; - -public static class CompilationHelper -{ - public static (Compilation Compilation, SemanticModel SemanticModel) Create(string code) - { - var syntaxTree = SyntaxFactory.ParseSyntaxTree(code, CSharpParseOptions.Default); - var assemblyName = Guid.NewGuid().ToString(); - var refAsmDir = Path.GetDirectoryName(typeof(object).Assembly.Location); - var references = new MetadataReference[] - { - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Private.CoreLib.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.Extensions.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Collections.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Linq.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Console.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Memory.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "netstandard.dll")), - MetadataReference.CreateFromFile(typeof(object).Assembly.Location), - }; - var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); - - var compilation = CSharpCompilation.Create(assemblyName, new [] { syntaxTree }, references, compilationOptions); - if (compilation.GetDiagnostics().Any(x => x.Severity == DiagnosticSeverity.Error)) - { - throw new InvalidOperationException("Failed to compile the source code. \n" + string.Join(Environment.NewLine, compilation.GetDiagnostics().Select(x => x.ToString()))); - } - return (compilation, compilation.GetSemanticModel(syntaxTree)); - } -} diff --git a/tests/MagicOnion.Generator.Tests/GenerateEnumFormatterTest.cs b/tests/MagicOnion.Generator.Tests/GenerateEnumFormatterTest.cs deleted file mode 100644 index c96986911..000000000 --- a/tests/MagicOnion.Generator.Tests/GenerateEnumFormatterTest.cs +++ /dev/null @@ -1,217 +0,0 @@ -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests; - -public class GenerateEnumFormatterTest -{ - readonly ITestOutputHelper testOutputHelper; - - public GenerateEnumFormatterTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task GenerateEnumFormatter_Return() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetEnumAsync(); - } - - public enum MyEnum - { - A, B, C - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - } - - - [Fact] - public async Task GenerateEnumFormatter_Return_Nullable() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetEnumAsync(); - } - - public enum MyEnum - { - A, B, C - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - } - - [Fact] - public async Task GenerateEnumFormatter_Parameter() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetEnumAsync(MyEnum a); - } - - public enum MyEnum - { - A, B, C - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - } - - [Fact] - public async Task GenerateEnumFormatter_Parameter_Nullable() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetEnumAsync(MyEnum? a); - } - - public enum MyEnum - { - A, B, C - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - } - - [Fact] - public async Task GenerateEnumFormatter_Nested() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetEnumAsync(MyClass.MyEnum? a); - } - - public class MyClass - { - public enum MyEnum - { - A, B, C - } - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyClass_MyEnumFormatter")); - } -} diff --git a/tests/MagicOnion.Generator.Tests/GenerateGenericsStreamingHubTest.cs b/tests/MagicOnion.Generator.Tests/GenerateGenericsStreamingHubTest.cs deleted file mode 100644 index 86785dccd..000000000 --- a/tests/MagicOnion.Generator.Tests/GenerateGenericsStreamingHubTest.cs +++ /dev/null @@ -1,1602 +0,0 @@ -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests; - -public class GenerateGenericsStreamingHubTest -{ - readonly ITestOutputHelper testOutputHelper; - - public GenerateGenericsStreamingHubTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task Parameters() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task A(MyGenericObject a); - Task B(MyGenericObject a); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Parameters_MultipleTypeArgs() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task A(MyGenericObject a); - Task B(MyGenericObject a); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Parameters_Nested() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task A(MyGenericObject> a); - Task B(MyGenericObject>> a); - Task C(MyGenericObject>> a); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - - [Fact] - public async Task Parameters_Nested_Enum() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task GetEnumAsync(MyGenericObject> arg0); - } - - public enum MyEnum - { - A, B, C - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>", - }); - } - - [Fact] - public async Task Parameters_Nested_Array() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task GetValuesAsync(MyGenericObject arg0); - } - - public class MyGenericObject - { - } - - public class MyNestedGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.ArrayFormatter" - }); - } - - [Fact] - public async Task Parameters_ListFormatter_KnownType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task GetStringValuesAsync(List arg0); - Task GetIntValuesAsync(List arg0); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - "global::MessagePack.Formatters.ListFormatter" - }); - } - - [Fact] - public async Task Parameters_ListFormatter_UserType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task GetValuesAsync(List arg0); - } - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - }); - } - - [Fact] - public async Task Parameters_ArrayFormatter_KnownType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task GetStringValuesAsync(string[] arg0); - Task GetIntValuesAsync(int[] arg0); - Task GetInt32ValuesAsync(Int32[] arg0); - Task GetSingleValuesAsync(float[] arg0); - Task GetBooleanValuesAsync(bool[] arg0); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().BeEmpty(); - } - - [Fact] - public async Task Parameters_ArrayFormatter_UserType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task GetValuesAsync(MyResponse[] arg0); - } - - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ArrayFormatter" - }); - } - - [Fact] - public async Task Return() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task> A(); - Task> B(); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Return_Nested() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task>> A(); - Task>>> B(); - Task>>> C(); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Return_MultipleTypeArgs() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task> A(); - Task> B(); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Return_Enum() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task> GetEnumAsync(); - } - - public enum MyEnum - { - A, B, C - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Return_Nested_Enum() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task>> GetEnumAsync(); - } - - public enum MyEnum - { - A, B, C - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>", - }); - } - - [Fact] - public async Task Return_Nested_Array() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task> GetValuesAsync(); - } - - public class MyGenericObject - { - } - - public class MyNestedGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "global::MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.ArrayFormatter" - }); - } - - [Fact] - public async Task Return_ListFormatter_KnownType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task> GetStringValuesAsync(); - Task> GetIntValuesAsync(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - "global::MessagePack.Formatters.ListFormatter" - }); - } - - [Fact] - public async Task Return_ListFormatter_UserType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task> GetValuesAsync(); - } - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - }); - } - - [Fact] - public async Task Return_ArrayFormatter_KnownType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task GetStringValuesAsync(); - Task GetIntValuesAsync(); - Task GetInt32ValuesAsync(); - Task GetSingleValuesAsync(); - Task GetBooleanValuesAsync(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().BeEmpty(); - } - - [Fact] - public async Task Return_ArrayFormatter_UserType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task GetValuesAsync(); - } - - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ArrayFormatter" - }); - } - - - [Fact] - public async Task HubReceiver() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void A(MyGenericObject a); - void B(MyGenericObject b); - } - public interface IMyHub : IStreamingHub - { - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task HubReceiver_Nested() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void A(MyGenericObject> a); - void B(MyGenericObject>> b); - void C(MyGenericObject>> c); - } - public interface IMyHub : IStreamingHub - { - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task HubReceiver_MultipleTypeArgs() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void A(MyGenericObject a); - void B(MyGenericObject b); - } - public interface IMyHub : IStreamingHub - { - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task HubReceiver_Enum() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void A(MyGenericObject a); - } - public interface IMyHub : IStreamingHub - { - } - - public enum MyEnum - { - A, B, C - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task HubReceiver_Nested_Enum() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void A(MyGenericObject> a); - } - public interface IMyHub : IStreamingHub - { - } - - public enum MyEnum - { - A, B, C - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>", - }); - } - - [Fact] - public async Task HubReceiver_Nested_Array() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void A(MyGenericObject a); - } - public interface IMyHub : IStreamingHub - { - } - - public class MyGenericObject - { - } - - public class MyNestedGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.ArrayFormatter" - }); - } - - [Fact] - public async Task HubReceiver_ListFormatter_KnownType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void A(List a); - void B(List b); - } - public interface IMyHub : IStreamingHub - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - "global::MessagePack.Formatters.ListFormatter" - }); - } - - [Fact] - public async Task HubReceiver_ListFormatter_UserType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void A(List a); - } - public interface IMyHub : IStreamingHub - { - } - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - }); - } - - [Fact] - public async Task HubReceiver_ArrayFormatter_KnownType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void A(string[] a); - void B(int[] a); - void C(Int32[] a); - void D(float[] a); - void E(bool[] a); - } - public interface IMyHub : IStreamingHub - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().BeEmpty(); - } - - [Fact] - public async Task HubReceiver_ArrayFormatter_UserType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyHub.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void A(MyResponse[] a); - } - public interface IMyHub : IStreamingHub - { - } - - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ArrayFormatter" - }); - } -} diff --git a/tests/MagicOnion.Generator.Tests/GenerateGenericsTest.cs b/tests/MagicOnion.Generator.Tests/GenerateGenericsTest.cs deleted file mode 100644 index 6e0145f13..000000000 --- a/tests/MagicOnion.Generator.Tests/GenerateGenericsTest.cs +++ /dev/null @@ -1,1028 +0,0 @@ -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests; - -public class GenerateGenericsTest -{ - readonly ITestOutputHelper testOutputHelper; - - public GenerateGenericsTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task Parameters() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; -using System.Collections.Generic; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult A(MyGenericObject a); - UnaryResult B(MyGenericObject a); - UnaryResult>> C(); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Parameters_MultipleTypeArgs() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult A(MyGenericObject a); - UnaryResult B(MyGenericObject a); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Parameters_Nested() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult A(MyGenericObject> a); - UnaryResult B(MyGenericObject>> a); - UnaryResult B(MyGenericObject>> a); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - - [Fact] - public async Task Parameters_Nested_Enum() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetEnumAsync(MyGenericObject> arg0); - } - - public enum MyEnum - { - A, B, C - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>", - }); - } - - [Fact] - public async Task Parameters_Nested_Array() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetValuesAsync(MyGenericObject arg0); - } - - public class MyGenericObject - { - } - - public class MyNestedGenericObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.ArrayFormatter" - }); - } - - [Fact] - public async Task Parameters_ListFormatter_KnownType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetStringValuesAsync(List arg0); - UnaryResult GetIntValuesAsync(List arg0); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - "global::MessagePack.Formatters.ListFormatter" - }); - } - - [Fact] - public async Task Parameters_ListFormatter_UserType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetValuesAsync(List arg0); - } - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - }); - } - - [Fact] - public async Task Parameters_ArrayFormatter_KnownType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetStringValuesAsync(string[] arg0); - UnaryResult GetIntValuesAsync(int[] arg0); - UnaryResult GetInt32ValuesAsync(Int32[] arg0); - UnaryResult GetSingleValuesAsync(float[] arg0); - UnaryResult GetBooleanValuesAsync(bool[] arg0); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().BeEmpty(); - } - - [Fact] - public async Task Parameters_ArrayFormatter_UserType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetValuesAsync(MyResponse[] arg0); - } - - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ArrayFormatter" - }); - } - - [Fact] - public async Task Return() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult> A(); - UnaryResult> B(); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Return_Nested() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult>> A(); - UnaryResult>>> B(); - UnaryResult>>> C(); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Return_MultipleTypeArgs() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult> A(); - UnaryResult> B(); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Return_Enum() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult> GetEnumAsync(); - } - - public enum MyEnum - { - A, B, C - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - - [Fact] - public async Task Return_Nested_Enum() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult>> GetEnumAsync(); - } - - public enum MyEnum - { - A, B, C - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name.EndsWith("MyEnumFormatter")); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>", - }); - } - - [Fact] - public async Task Return_Nested_Array() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult> GetValuesAsync(); - } - - public class MyGenericObject - { - } - - public class MyNestedGenericObject - { - } -} - -// Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) -namespace MessagePack.Formatters.TempProject -{ - public class MyGenericObjectFormatter : MessagePack.Formatters.IMessagePackFormatter> - { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyGenericObject value, MessagePackSerializerOptions options) => throw new NotImplementedException(); - public global::TempProject.MyGenericObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => throw new NotImplementedException(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.ArrayFormatter" - }); - } - - [Fact] - public async Task Return_ListFormatter_KnownType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult> GetStringValuesAsync(); - UnaryResult> GetIntValuesAsync(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - "global::MessagePack.Formatters.ListFormatter" - }); - } - - [Fact] - public async Task Return_ListFormatter_UserType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult> GetValuesAsync(); - } - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - }); - } - - [Fact] - public async Task Return_ArrayFormatter_KnownType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetStringValuesAsync(); - UnaryResult GetIntValuesAsync(); - UnaryResult GetInt32ValuesAsync(); - UnaryResult GetSingleValuesAsync(); - UnaryResult GetBooleanValuesAsync(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().BeEmpty(); - } - - [Fact] - public async Task Return_ArrayFormatter_UserType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult GetValuesAsync(); - } - - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ArrayFormatter" - }); - } - - - [Fact] - public async Task KnownFormatters() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult> MethodList(List args); - UnaryResult> MethodIList(); - UnaryResult> MethodIROList(); - - UnaryResult> MethodDictionary(); - UnaryResult> MethodIDictionary(); - UnaryResult> MethodIRODictionary(); - - UnaryResult> MethodIEnumerable(); - UnaryResult> MethodICollection(); - UnaryResult> MethodIROCollection(); - - UnaryResult> MethodILookup(); - UnaryResult> MethodIGrouping(); - } - public class MyResponse - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - tempWorkspace.OutputDirectory, - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - "global::MessagePack.Formatters.ListFormatter", - "global::MessagePack.Formatters.InterfaceListFormatter2", - "global::MessagePack.Formatters.InterfaceReadOnlyListFormatter", - - "global::MessagePack.Formatters.DictionaryFormatter", - "global::MessagePack.Formatters.InterfaceDictionaryFormatter", - "global::MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter", - - "global::MessagePack.Formatters.InterfaceEnumerableFormatter", - "global::MessagePack.Formatters.InterfaceCollectionFormatter2", - "global::MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter", - - "global::MessagePack.Formatters.InterfaceLookupFormatter", - "global::MessagePack.Formatters.InterfaceGroupingFormatter", - - }); - } -} diff --git a/tests/MagicOnion.Generator.Tests/GenerateRawStreamingTest.cs b/tests/MagicOnion.Generator.Tests/GenerateRawStreamingTest.cs deleted file mode 100644 index 8292e1366..000000000 --- a/tests/MagicOnion.Generator.Tests/GenerateRawStreamingTest.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests; - -public class GenerateRawStreamingTest -{ - readonly ITestOutputHelper testOutputHelper; - - public GenerateRawStreamingTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task StreamingResult() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; -using System.Threading.Tasks; - -namespace TempProject -{ - public interface IMyService : IService - { - Task> ClientStreamingAsync(); - Task> ServerStreamingAsync(); - Task> DuplexStreamingAsync(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } -} diff --git a/tests/MagicOnion.Generator.Tests/GenerateServiceTest.cs b/tests/MagicOnion.Generator.Tests/GenerateServiceTest.cs deleted file mode 100644 index a2562b12a..000000000 --- a/tests/MagicOnion.Generator.Tests/GenerateServiceTest.cs +++ /dev/null @@ -1,324 +0,0 @@ -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests; - -public class GenerateServiceTest -{ - readonly ITestOutputHelper testOutputHelper; - - public GenerateServiceTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task Return_UnaryResultNonGeneric() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Return_UnaryResultOfT() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Return_UnaryResultOfValueType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Return_UnaryResultOfRefType() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Invalid_Return_TaskOfUnaryResultOfT() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - Task> A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await Assert.ThrowsAsync(async () =>await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - )); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - - [Fact] - public async Task Return_StreamingResult() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; -using System.Threading.Tasks; - -namespace TempProject -{ - public interface IMyService : IService - { - Task> ClientStreamingAsync(); - Task> ServerStreamingAsync(); - Task> DuplexStreamingAsync(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Invalid_Return_NonGenerics() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - int A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await Assert.ThrowsAsync(async () => - { - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - }); - } - - [Fact] - public async Task Invalid_Return_NonSupportedUnaryResultOfT() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult> A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await Assert.ThrowsAsync(async () => - { - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - }); - } - - [Fact] - public async Task Invalid_Return_RawStreaming_NonTask() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - ClientStreamingResult ClientStreamingAsync(); - ServerStreamingResult ServerStreamingAsync(); - DuplexStreamingResult DuplexStreamingAsync(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await Assert.ThrowsAsync(async () => - { - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - }); - } -} diff --git a/tests/MagicOnion.Generator.Tests/GenerateStreamingHub.cs b/tests/MagicOnion.Generator.Tests/GenerateStreamingHub.cs deleted file mode 100644 index 935699fac..000000000 --- a/tests/MagicOnion.Generator.Tests/GenerateStreamingHub.cs +++ /dev/null @@ -1,534 +0,0 @@ -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests; - -public class GenerateStreamingHubTest -{ - readonly ITestOutputHelper testOutputHelper; - - public GenerateStreamingHubTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task Complex() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void OnMessage(); - void OnMessage2(MyObject a); - void OnMessage3(MyObject a, string b, int c); - - } - public interface IMyHub : IStreamingHub - { - Task A(); - Task B(MyObject a); - Task C(MyObject a, string b); - Task D(MyObject a, string b, int c); - Task E(MyObject a, string b, int c); - } - - [MessagePackObject] - public class MyObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task HubReceiver_Parameter_Zero() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void OnMessage(); - } - public interface IMyHub : IStreamingHub - { - Task A(MyObject a); - } - - [MessagePackObject] - public class MyObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task HubReceiver_Parameter_One() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void OnMessage(MyObject arg0); - } - public interface IMyHub : IStreamingHub - { - Task A(MyObject a); - } - - [MessagePackObject] - public class MyObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task HubReceiver_Parameter_Many() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void OnMessage(MyObject arg0, int arg1, string arg2); - } - public interface IMyHub : IStreamingHub - { - Task A(MyObject a); - } - - [MessagePackObject] - public class MyObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Return_Task() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task A(MyObject a); - } - - [MessagePackObject] - public class MyObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Return_TaskOfT() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task A(MyObject a); - } - - [MessagePackObject] - public class MyObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Return_ValueTask() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - ValueTask A(MyObject a); - } - - [MessagePackObject] - public class MyObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Return_ValueTaskOfT() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - ValueTask A(MyObject a); - } - - [MessagePackObject] - public class MyObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Invalid_Return_Void() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - void A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - - var ex = await Record.ExceptionAsync(async () => await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - )); - - ex.Should().NotBeNull(); - ex.Should().BeOfType(); - ex.Message.Should().Contain("IMyHub.A' has unsupported return type"); - } - - - [Fact] - public async Task Invalid_HubReceiver_ReturnsNotVoid() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - Task B(); - } - public interface IMyHub : IStreamingHub - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - - var ex = await Record.ExceptionAsync(async () => await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - )); - - ex.Should().NotBeNull(); - ex.Should().BeOfType(); - ex.Message.Should().Contain("IMyHubReceiver.B' has unsupported return type"); - } - - [Fact] - public async Task Parameter_Zero() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Parameter_One() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task A(string arg0); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task Parameter_Many() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver { } - public interface IMyHub : IStreamingHub - { - Task A(string arg0, int arg1, bool arg2); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - } -} diff --git a/tests/MagicOnion.Generator.Tests/GenerateTest.cs b/tests/MagicOnion.Generator.Tests/GenerateTest.cs deleted file mode 100644 index 557b4c9e0..000000000 --- a/tests/MagicOnion.Generator.Tests/GenerateTest.cs +++ /dev/null @@ -1,436 +0,0 @@ -using MagicOnion.Generator.Utils; -using Microsoft.CodeAnalysis; -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests; - -public class GenerateTest -{ - readonly ITestOutputHelper testOutputHelper; - - const string MyServiceSourceCode = @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult A(); - } -} - "; - - public GenerateTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task CsProjContainsAnalyzerReferenceUpdate() - { - var options = TemporaryProjectWorkareaOptions.Default with - { - AdditionalCsProjectContent = @" - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - ", - }; - using var tempWorkspace = TemporaryProjectWorkarea.Create(options); - tempWorkspace.AddFileToProject("IMyService.cs", MyServiceSourceCode); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var outputCompilation = tempWorkspace.GetOutputCompilation(); - outputCompilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task CsProjContainsAnalyzerReferenceExclude() - { - var options = TemporaryProjectWorkareaOptions.Default with - { - AdditionalCsProjectContent = @" - - - - ", - }; - using var tempWorkspace = TemporaryProjectWorkarea.Create(options); - tempWorkspace.AddFileToProject("IMyService.cs", MyServiceSourceCode); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var outputCompilation = tempWorkspace.GetOutputCompilation(); - outputCompilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task CsProjContainsAnalyzerReferenceRemove() - { - var options = TemporaryProjectWorkareaOptions.Default with - { - AdditionalCsProjectContent = @" - - - - ", - }; - using var tempWorkspace = TemporaryProjectWorkarea.Create(options); - tempWorkspace.AddFileToProject("IMyService.cs", MyServiceSourceCode); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var outputCompilation = tempWorkspace.GetOutputCompilation(); - outputCompilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task CsProjTargetsNet5() - { - var options = TemporaryProjectWorkareaOptions.Default with - { - TargetFramework = "net5.0", - }; - using var tempWorkspace = TemporaryProjectWorkarea.Create(options); - tempWorkspace.AddFileToProject("IMyService.cs", MyServiceSourceCode); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - var outputCompilation = tempWorkspace.GetOutputCompilation(); - outputCompilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task ImplicitUsings_PropertyGroup_Enable() - { - var options = TemporaryProjectWorkareaOptions.Default with - { - ImplicitUsings = true, - }; - using var tempWorkspace = TemporaryProjectWorkarea.Create(options); - tempWorkspace.AddFileToProject("IMyService.cs", """ - using MagicOnion; - using MessagePack; - - namespace MyNamespace; - - public interface IMyService : IService - { - // ImplicitUsings: Microsoft.NET.Sdk - // global::System - // global::System.Collections.Generic - // global::System.IO - // global::System.Linq - // global::System.Net.Http - // global::System.Threading - // global::System.Threading.Tasks - UnaryResult A(Int32 arg0, IReadOnlyList arg1, FileMode arg2, ILookup arg3, ClientCertificateOption arg4, ApartmentState arg5, TaskCreationOptions arg6); - } - """); - - // Try create a compilation from the temporary project. - var sourceProjectCompilation = await PseudoCompilation.CreateFromProjectAsync( - new[] { tempWorkspace.CsProjectPath }, - Array.Empty(), - new MagicOnionGeneratorTestOutputLogger(testOutputHelper), - CancellationToken.None - ); - - // Generate codes and get a compilation of the project with generated code. - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - var outputCompilation = tempWorkspace.GetOutputCompilation(); - - // Assert - sourceProjectCompilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - outputCompilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task ImplicitUsings_PropertyGroup_Disable() - { - var options = TemporaryProjectWorkareaOptions.Default with - { - ImplicitUsings = false, - }; - using var tempWorkspace = TemporaryProjectWorkarea.Create(options); - tempWorkspace.AddFileToProject("IMyService.cs", """ - using MagicOnion; - using MessagePack; - - namespace MyNamespace; - - public interface IMyService : IService - { - // ImplicitUsings: Microsoft.NET.Sdk - // global::System - // global::System.Collections.Generic - // global::System.IO - // global::System.Linq - // global::System.Net.Http - // global::System.Threading - // global::System.Threading.Tasks - UnaryResult A(Int32 arg0, IReadOnlyList arg1, FileMode arg2, ILookup arg3, ClientCertificateOption arg4, ApartmentState arg5, TaskCreationOptions arg6); - } - """); - - // Try create a compilation from the temporary project. - var sourceProjectCompilation = await PseudoCompilation.CreateFromProjectAsync( - new[] { tempWorkspace.CsProjectPath }, - Array.Empty(), - new MagicOnionGeneratorTestOutputLogger(testOutputHelper), - CancellationToken.None - ); - - // Generate codes and get a compilation of the project with generated code. - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - var outputCompilation = tempWorkspace.GetOutputCompilation(); - - // Assert - sourceProjectCompilation.GetDiagnostics().Should().Contain(x => x.Severity == DiagnosticSeverity.Error); // Failed to compile the project. - outputCompilation.GetCompilationErrors().Should().NotBeEmpty(); - } - - [Fact] - public async Task GlobalUsingsInProject() - { - var options = TemporaryProjectWorkareaOptions.Default with - { - ImplicitUsings = false, - Usings = new [] - { - (Namespace: "System", Static: false, Remove: false), - (Namespace: "System.Collections.Generic", Static: false, Remove: false), - (Namespace: "System.IO", Static: false, Remove: false), - (Namespace: "System.Linq", Static: false, Remove: false), - (Namespace: "System.Net.Http", Static: false, Remove: false), - (Namespace: "System.Threading", Static: false, Remove: false), - (Namespace: "System.Threading.Tasks", Static: false, Remove: false), - - (Namespace: "MagicOnion", Static: false, Remove: false), - (Namespace: "MessagePack", Static: false, Remove: false), - }, - }; - using var tempWorkspace = TemporaryProjectWorkarea.Create(options); - tempWorkspace.AddFileToProject("IMyService.cs", """ - namespace MyNamespace; - - public interface IMyService : IService - { - // ImplicitUsings: Microsoft.NET.Sdk - // global::System - // global::System.Collections.Generic - // global::System.IO - // global::System.Linq - // global::System.Net.Http - // global::System.Threading - // global::System.Threading.Tasks - UnaryResult A(Int32 arg0, IReadOnlyList arg1, FileMode arg2, ILookup arg3, ClientCertificateOption arg4, ApartmentState arg5, TaskCreationOptions arg6); - } - """); - - // Try create a compilation from the temporary project. - var sourceProjectCompilation = await PseudoCompilation.CreateFromProjectAsync( - new[] { tempWorkspace.CsProjectPath }, - Array.Empty(), - new MagicOnionGeneratorTestOutputLogger(testOutputHelper), - CancellationToken.None - ); - - // Generate codes and get a compilation of the project with generated code. - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - var outputCompilation = tempWorkspace.GetOutputCompilation(); - - // Assert - sourceProjectCompilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - outputCompilation.GetCompilationErrors().Should().BeEmpty(); - } - - [Fact] - public async Task GlobalUsingsInProject_Remove() - { - var options = TemporaryProjectWorkareaOptions.Default with - { - ImplicitUsings = false, - Usings = new [] - { - (Namespace: "System", Static: false, Remove: false), - (Namespace: "System.Collections.Generic", Static: false, Remove: false), - (Namespace: "System.IO", Static: false, Remove: false), - (Namespace: "System.Linq", Static: false, Remove: false), - (Namespace: "System.Net.Http", Static: false, Remove: false), - (Namespace: "System.Threading", Static: false, Remove: false), - (Namespace: "System.Threading.Tasks", Static: false, Remove: false), - - (Namespace: "MagicOnion", Static: false, Remove: false), - (Namespace: "MessagePack", Static: false, Remove: false), - - // Remove - (Namespace: "MagicOnion", Static: false, Remove: true), - }, - }; - using var tempWorkspace = TemporaryProjectWorkarea.Create(options); - tempWorkspace.AddFileToProject("IMyService.cs", """ - namespace MyNamespace; - - public interface IMyService : IService - { - // ImplicitUsings: Microsoft.NET.Sdk - // global::System - // global::System.Collections.Generic - // global::System.IO - // global::System.Linq - // global::System.Net.Http - // global::System.Threading - // global::System.Threading.Tasks - UnaryResult A(Int32 arg0, IReadOnlyList arg1, FileMode arg2, ILookup arg3, ClientCertificateOption arg4, ApartmentState arg5, TaskCreationOptions arg6); - } - """); - - // Try create a compilation from the temporary project. - var sourceProjectCompilation = await PseudoCompilation.CreateFromProjectAsync( - new[] { tempWorkspace.CsProjectPath }, - Array.Empty(), - new MagicOnionGeneratorTestOutputLogger(testOutputHelper), - CancellationToken.None - ); - - // Assert - sourceProjectCompilation.GetDiagnostics().Should().Contain(x => x.Severity == DiagnosticSeverity.Error); // the compilation should have some errors. - } - - [Fact] - public async Task SharedProject() - { - var options = TemporaryProjectWorkareaOptions.Default with - { - AdditionalCsProjectContent = @" - - ", - }; - using var tempWorkspace = TemporaryProjectWorkarea.Create(options); - var sharedDir = Path.GetFullPath(Path.Combine(tempWorkspace.ProjectDirectory, "..", "Shared", "SubDir")); - Directory.CreateDirectory(sharedDir); - // /Shared/SubDir/MyShared.projeitems - File.WriteAllText(Path.Combine(sharedDir, "MyShared.projeitems"), ""); - // /Shared/SubDir/IMyService.cs - File.WriteAllText(Path.Combine(sharedDir, "IMyService.cs"), """ - using System; - using System.Threading.Tasks; - using MessagePack; - using MagicOnion; - - namespace TempProject - { - public interface IMyService : IService - { - UnaryResult A(); - } - } - """); - // /Shared/IYetAnotherMyService.cs (This file should be ignored.) - File.WriteAllText(Path.Combine(Path.GetDirectoryName(sharedDir), "IYetAnotherMyService.cs"), """ - using System; - using System.Threading.Tasks; - using MessagePack; - using MagicOnion; - - namespace TempProject - { - public interface IYetAnotherMyService : IService - { - UnaryResult A(); - } - } - """); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - // NOTE: GetOutputCompilation only refers under the ProjectDirectory and OutputDirectory. - Directory.Move(sharedDir, Path.Combine(tempWorkspace.ProjectDirectory, "Shared")); - - var outputCompilation = tempWorkspace.GetOutputCompilation(); - outputCompilation.GetCompilationErrors().Should().BeEmpty(); - - var symbols = outputCompilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().NotContain(x => x.Name.Contains("YetAnotherMyService")); - } -} diff --git a/tests/MagicOnion.Generator.Tests/GenerateWithIfDirectiveTest.cs b/tests/MagicOnion.Generator.Tests/GenerateWithIfDirectiveTest.cs deleted file mode 100644 index dd8fd47f5..000000000 --- a/tests/MagicOnion.Generator.Tests/GenerateWithIfDirectiveTest.cs +++ /dev/null @@ -1,476 +0,0 @@ -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests; - -public class GenerateWithIfDirectiveTest -{ - readonly ITestOutputHelper testOutputHelper; - - public GenerateWithIfDirectiveTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task StreamingHub_Interface() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyHubReceiver - { - void OnMessage(int a); - } - public interface IMyHub : IStreamingHub - { - Task A(int a); - } - - [GenerateIfDirective(""MYDEBUG || DEBUG"")] - public interface IMyDebugHub : IStreamingHub - { - Task A(int a); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - { - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name == "MyHubClient"); - symbols.Should().NotContain(x => x.Name == "MyDebugHubClient"); - } - { - var compilation = tempWorkspace.GetOutputCompilation(new[] { "MYDEBUG" }); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name == "MyHubClient"); - symbols.Should().Contain(x => x.Name == "MyDebugHubClient"); - } - } - - [Fact] - public async Task Service_Interface() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult A(); - } - - [GenerateIfDirective(""MYDEBUG || DEBUG"")] - public interface IMyServiceForDebug : IService - { - UnaryResult A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - { - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name == "MyServiceClient"); - symbols.Should().NotContain(x => x.Name == "MyServiceForDebugClient"); - } - { - var compilation = tempWorkspace.GetOutputCompilation(new [] { "MYDEBUG" }); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name == "MyServiceClient"); - symbols.Should().Contain(x => x.Name == "MyServiceForDebugClient"); - } - } - - - [Fact] - public async Task GenerateDefineDebug_Service_Interface() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - public interface IMyService : IService - { - UnaryResult A(); - } - - [GenerateDefineDebug] - public interface IMyServiceForDebug : IService - { - UnaryResult A(); - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - { - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name == "MyServiceClient"); - symbols.Should().NotContain(x => x.Name == "MyServiceForDebugClient"); - } - { - var compilation = tempWorkspace.GetOutputCompilation(new[] { "DEBUG" }); - compilation.GetCompilationErrors().Should().BeEmpty(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name == "MyServiceClient"); - symbols.Should().Contain(x => x.Name == "MyServiceForDebugClient"); - } - } - - [Fact] - public async Task Formatters() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - [GenerateIfDirective(""MYDEBUG || DEBUG"")] - public interface IMyServiceForDebug : IService - { - UnaryResult A(MyDebugObject a, MyDebugObject b); - UnaryResult B(MyObject a, MyDebugObject b); - UnaryResult C(MyObject a, MyObject2 b); - } - - [GenerateIfDirective(""CUSTOM_DEBUG"")] - public interface IMyServiceForCustomDebug : IService - { - UnaryResult A(MyDebugObject a, MyDebugObjectForCustomDebug b); - } - - [MessagePackObject] - public class MyDebugObject - { - } - - [MessagePackObject] - public class MyDebugObjectForCustomDebug - { - } - - [MessagePackObject] - public class MyDebugReturnObject - { - } - - public interface IMyService : IService - { - UnaryResult A(MyObject a, MyObject b); - UnaryResult B(MyObject a, MyObject2 b); - } - - [MessagePackObject] - public class MyObject - { - } - [MessagePackObject] - public class MyObject2 - { - } - [MessagePackObject] - public class MyReturnObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - { - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MagicOnion.DynamicArgumentTupleFormatter", - "global::MagicOnion.DynamicArgumentTupleFormatter", - }); - compilation.GetResolverKnownFormatterTypes().Should().NotContain(new[] - { - "global::MagicOnion.DynamicArgumentTupleFormatter", - "global::MagicOnion.DynamicArgumentTupleFormatter", - }); - } - - { - var compilation = tempWorkspace.GetOutputCompilation(new[] { "MYDEBUG" }); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MagicOnion.DynamicArgumentTupleFormatter", - "global::MagicOnion.DynamicArgumentTupleFormatter", - "global::MagicOnion.DynamicArgumentTupleFormatter", - }); - compilation.GetResolverKnownFormatterTypes().Should().NotContain(new[] - { - "global::MagicOnion.DynamicArgumentTupleFormatter", - }); - } - { - var compilation = tempWorkspace.GetOutputCompilation(new[] { "CUSTOM_DEBUG" }); - compilation.GetCompilationErrors().Should().BeEmpty(); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MagicOnion.DynamicArgumentTupleFormatter", - "global::MagicOnion.DynamicArgumentTupleFormatter", - }); - compilation.GetResolverKnownFormatterTypes().Should().NotContain(new[] - { - "global::MagicOnion.DynamicArgumentTupleFormatter", - }); - } - } - - [Fact] - public async Task Generics() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - [GenerateIfDirective(""MYDEBUG || DEBUG"")] - public interface IMyService : IService - { - UnaryResult A(MyGenericObject a); - UnaryResult B(MyGenericObject a); - } - - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - { - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetResolverKnownFormatterTypes().Should().NotContain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - { - var compilation = tempWorkspace.GetOutputCompilation(new [] { "MYDEBUG" }); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - } - - - [Fact] - public async Task MergeConditions() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - [GenerateIfDirective(""MYDEBUG"")] - public interface IMyDebugService : IService - { - UnaryResult A(MyGenericObject a); - } - - [GenerateIfDirective(""CUSTOM_DEBUG"")] - public interface IMyYetAnotherDebugService : IService - { - UnaryResult A(MyGenericObject a); - } - - [MessagePackObject] - public class MyGenericObject {} -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - { - var compilation = tempWorkspace.GetOutputCompilation(); - compilation.GetResolverKnownFormatterTypes().Should().NotContain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - { - var compilation = tempWorkspace.GetOutputCompilation(new[] { "MYDEBUG" }); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - { - var compilation = tempWorkspace.GetOutputCompilation(new[] { "CUSTOM_DEBUG" }); - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter", - }); - } - } - - [Fact] - public async Task Generate() - { - using var tempWorkspace = TemporaryProjectWorkarea.Create(); - tempWorkspace.AddFileToProject("IMyService.cs", @" -using System; -using System.Threading.Tasks; -using MessagePack; -using MagicOnion; - -namespace TempProject -{ - [GenerateIfDirective(""MYDEBUG || DEBUG"")] - public interface IMyDebugService : IService - { - UnaryResult A(int a, int b, int c); - } - public interface IMyService : IService - { - UnaryResult A(int a, int b, int c); - } - public interface IMyHubReceiver - { - void OnMessage(int a, int b, int c); - } - public interface IMyHub : IStreamingHub - { - Task A(int a, int b, int c); - } - [MessagePackObject] - public class MyObject - { - } - - [MessagePackObject] - public class MyGenericObject - { - } -} - "); - - var compiler = new MagicOnionCompiler(new MagicOnionGeneratorTestOutputLogger(testOutputHelper), CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkspace.CsProjectPath, - Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), - true, - "TempProject.Generated", - "", - "MessagePack.Formatters", - SerializerType.MessagePack - ); - - { - var compilation = tempWorkspace.GetOutputCompilation(); - var formatters = compilation.GetResolverKnownFormatterTypes(); - formatters.Should().ContainSingle(x => x == "global::MagicOnion.DynamicArgumentTupleFormatter"); - } - { - var compilation = tempWorkspace.GetOutputCompilation(new[] { "MYDEBUG" }); - var formatters = compilation.GetResolverKnownFormatterTypes(); - formatters.Should().ContainSingle(x => x == "global::MagicOnion.DynamicArgumentTupleFormatter"); - } - } -} diff --git a/tests/MagicOnion.Generator.Tests/MagicOnionGeneratorTestOutputLogger.cs b/tests/MagicOnion.Generator.Tests/MagicOnionGeneratorTestOutputLogger.cs deleted file mode 100644 index e00b813d2..000000000 --- a/tests/MagicOnion.Generator.Tests/MagicOnionGeneratorTestOutputLogger.cs +++ /dev/null @@ -1,22 +0,0 @@ -using MagicOnion.Generator.Internal; -using Xunit.Abstractions; - -namespace MagicOnion.Generator.Tests; - -public class MagicOnionGeneratorTestOutputLogger : IMagicOnionGeneratorLogger -{ - readonly ITestOutputHelper outputHelper; - - public MagicOnionGeneratorTestOutputLogger(ITestOutputHelper outputHelper) - { - this.outputHelper = outputHelper; - } - -#if FALSE - public void Trace(string message) => outputHelper.WriteLine(message); -#else - public void Trace(string message) {} -#endif - public void Information(string message) => outputHelper.WriteLine(message); - public void Error(string message, Exception exception = null) => outputHelper.WriteLine(message); -} diff --git a/tests/MagicOnion.Generator.Tests/TemporaryProjectWorkarea.cs b/tests/MagicOnion.Generator.Tests/TemporaryProjectWorkarea.cs deleted file mode 100644 index 6edc424a0..000000000 --- a/tests/MagicOnion.Generator.Tests/TemporaryProjectWorkarea.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System.Reflection; -using System.Runtime.Loader; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; - -namespace MagicOnion.Generator.Tests; - -/// -/// Provides a temporary work area for unit testing. -/// -public class TemporaryProjectWorkarea : IDisposable -{ - readonly TemporaryProjectWorkareaOptions options; - readonly string tempDirPath; - readonly string csprojFileName = "TempProject.csproj"; - - public string CsProjectPath { get; } - - public string ProjectDirectory { get; } - - public string OutputDirectory { get; } - - /// - /// Gets the identifier of the workarea. - /// - public Guid WorkareaId { get; } - - public static TemporaryProjectWorkarea Create(bool cleanOnDisposing = true) - { - return new TemporaryProjectWorkarea(TemporaryProjectWorkareaOptions.Default with { CleanOnDisposing = cleanOnDisposing }); - } - - public static TemporaryProjectWorkarea Create(TemporaryProjectWorkareaOptions options) - { - return new TemporaryProjectWorkarea(options ?? throw new ArgumentNullException(nameof(options))); - } - - TemporaryProjectWorkarea(TemporaryProjectWorkareaOptions options) - { - WorkareaId = Guid.NewGuid(); - - this.options = options ?? throw new ArgumentNullException(nameof(options)); - this.tempDirPath = Path.Combine(Path.GetTempPath(), $"MagicOnion.Generator.Tests-{Guid.NewGuid()}"); - - ProjectDirectory = Path.Combine(tempDirPath, "Project"); - OutputDirectory = Path.Combine(tempDirPath, "Output"); - - Directory.CreateDirectory(ProjectDirectory); - Directory.CreateDirectory(OutputDirectory); - - var solutionRootDir = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "../../../../..")); - var abstractionsProjectDir = Path.Combine(solutionRootDir, "src/MagicOnion.Abstractions/MagicOnion.Abstractions.csproj"); - - CsProjectPath = Path.Combine(ProjectDirectory, csprojFileName); - var csprojContents = $@" - - - {options.TargetFramework} - {(options.ImplicitUsings ? "enable" : "")} - {string.Join("", (options.Usings ?? Array.Empty<(string Namespace, bool Static, bool Remove)>()).Select(x => $@""))} - - - - - {string.Join("", (options.AdditionalProjectReferences ?? Array.Empty()).Select(x => $@""))} - {string.Join("", (options.AdditionalPackageReferences ?? Array.Empty()).Select(x => $@""))} - - {options.AdditionalCsProjectContent} - -"; - AddFileToProject(csprojFileName, csprojContents); - } - - public void AddFileToProject(string fileName, string contents) - { - File.WriteAllText(Path.Combine(ProjectDirectory, fileName), contents.Trim()); - } - - public OutputCompilation GetOutputCompilation(IReadOnlyList preprocessorSymbols = null) - { - var refAsmDir = Path.GetDirectoryName(typeof(object).Assembly.Location); - - var parseOptions = CSharpParseOptions.Default - .WithLanguageVersion(options.LangVersion) - .WithPreprocessorSymbols(preprocessorSymbols ?? Array.Empty()); - - var compilation = CSharpCompilation.Create(Guid.NewGuid().ToString()) - .AddSyntaxTrees(CSharpSyntaxTree.ParseText("", parseOptions)) - .AddSyntaxTrees( - Directory.EnumerateFiles(ProjectDirectory, "*.cs", SearchOption.AllDirectories) - .Concat(Directory.EnumerateFiles(OutputDirectory, "*.cs", SearchOption.AllDirectories)) - .Select(x => CSharpSyntaxTree.ParseText(File.ReadAllText(x), parseOptions, x))) - .AddReferences( - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Private.CoreLib.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.Extensions.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Collections.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Linq.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Net.Http.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Console.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Memory.dll")), - MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "netstandard.dll")), - MetadataReference.CreateFromFile(typeof(object).Assembly.Location), - - MetadataReference.CreateFromFile(typeof(Grpc.Core.AsyncUnaryCall<>).Assembly.Location), // Grpc.Core.Api - MetadataReference.CreateFromFile(typeof(MagicOnion.Client.MagicOnionClient).Assembly.Location), // MagicOnion.Client - MetadataReference.CreateFromFile(typeof(MagicOnion.MagicOnionMarshallers).Assembly.Location), // MagicOnion.Shared - MetadataReference.CreateFromFile(typeof(MagicOnion.IService<>).Assembly.Location), // MagicOnion.Abstractions - MetadataReference.CreateFromFile(typeof(MessagePack.IFormatterResolver).Assembly.Location), // MessagePack - MetadataReference.CreateFromFile(typeof(MessagePack.MessagePackObjectAttribute).Assembly.Location) // MessagePack.Annotations - ) - .AddReferences((options.AdditionalReferences ?? Array.Empty()).Select(x => MetadataReference.CreateFromFile(x))) - .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); - - if (options.ImplicitUsings || options.Usings is not null) - { - var globalUsings = new (string Namespace, bool Static, bool Remove)[] - { - (Namespace: "global::System", Static: false, Remove: false), - (Namespace: "global::System.Collections.Generic", Static: false, Remove: false), - (Namespace: "global::System.IO", Static: false, Remove: false), - (Namespace: "global::System.Linq", Static: false, Remove: false), - (Namespace: "global::System.Net.Http", Static: false, Remove: false), - (Namespace: "global::System.Threading", Static: false, Remove: false), - (Namespace: "global::System.Threading.Tasks", Static: false, Remove: false), - } - .Concat(options.Usings?.ToArray() ?? Array.Empty<(string Namespace, bool Static, bool Remove)>()) - .ToHashSet(); - - compilation = compilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText(string.Join(Environment.NewLine, globalUsings.Select(x => $"global using {(x.Static ? "static" : "")} {x.Namespace};")), parseOptions)); - } - - return new OutputCompilation(this, compilation); - } - - public void Dispose() - { - if (options.CleanOnDisposing) - { - Directory.Delete(tempDirPath, true); - } - } -} - -public record TemporaryProjectWorkareaOptions( - bool CleanOnDisposing = true, - string TargetFramework = "netstandard2.0", - string AdditionalCsProjectContent = "", - IEnumerable AdditionalReferences = default, - IEnumerable AdditionalPackageReferences = default, - IEnumerable AdditionalProjectReferences = default, - LanguageVersion LangVersion = LanguageVersion.Default, - bool ImplicitUsings = false, - IEnumerable<(string Namespace, bool Static, bool Remove)> Usings = default -) -{ - public static TemporaryProjectWorkareaOptions Default { get; } = new TemporaryProjectWorkareaOptions(); - -} - -public class OutputCompilation -{ - readonly TemporaryProjectWorkarea workarea; - - public Compilation Compilation { get; } - - public OutputCompilation(TemporaryProjectWorkarea workarea, Compilation compilation) - { - this.workarea = workarea; - this.Compilation = compilation ?? throw new ArgumentNullException(nameof(compilation)); - } - - public INamedTypeSymbol[] GetNamedTypeSymbolsFromGenerated() - { - return Compilation.SyntaxTrees - .Select(x => Compilation.GetSemanticModel(x)) - .SelectMany(semanticModel => - { - return semanticModel.SyntaxTree.GetRoot() - .DescendantNodes() - .Select(x => semanticModel.GetDeclaredSymbol(x)) - .OfType(); - }) - .ToArray(); - } - - public IReadOnlyList GetResolverKnownFormatterTypes() - { - return Compilation.SyntaxTrees - .SelectMany(x => x.GetRoot() - .DescendantNodes() - .OfType() - .Where(x => x.Identifier.ToString().EndsWith("ResolverGetFormatterHelper")) - .SelectMany(x => x.DescendantNodes()) - .OfType() - .Where(x => x.Identifier.ToString() == "GetFormatter") - .SelectMany(x => x.DescendantNodes()) - .OfType() - .SelectMany(x => x.DescendantNodes()) - .OfType() - .SelectMany(x => x.ChildNodes()) - .Where(x => x is QualifiedNameSyntax || x is IdentifierNameSyntax || x is GenericNameSyntax || x is PredefinedTypeSyntax) - .Select(x => x.ToString())) - .ToArray(); - } - - public IReadOnlyList GetCompilationErrors() - { - return Compilation.GetDiagnostics().Where(x => x.Severity == DiagnosticSeverity.Error).ToArray(); - } - - /// - /// Load the generated assembly and execute the code in that context. - /// - public void ExecuteWithGeneratedAssembly(Action action) - { - var memoryStream = new MemoryStream(); - Compilation.Emit(memoryStream); - memoryStream.Position = 0; - - var assemblyLoadContext = new AssemblyLoadContext($"TempProject-{workarea.WorkareaId}", isCollectible: true); - try - { - assemblyLoadContext.LoadFromStream(memoryStream); - var assembly = assemblyLoadContext.Assemblies.First(); - action(assemblyLoadContext, assembly); - } - finally - { - assemblyLoadContext.Unload(); - } - } -} diff --git a/tests/MagicOnion.Generator.Tests/Usings.cs b/tests/MagicOnion.Generator.Tests/Usings.cs deleted file mode 100644 index 777db42fa..000000000 --- a/tests/MagicOnion.Generator.Tests/Usings.cs +++ /dev/null @@ -1,5 +0,0 @@ -global using Xunit; -global using FluentAssertions; - -global using Grpc.Core; -global using MessagePack; \ No newline at end of file From 8b7bc89315b8a12d4bf6d337cf964cca6d3b2cc7 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 16:46:40 +0900 Subject: [PATCH 20/66] Remove legacy generator test project --- .../MagicOnion.Generator.Tests.csproj | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 tests/MagicOnion.Generator.Tests/MagicOnion.Generator.Tests.csproj diff --git a/tests/MagicOnion.Generator.Tests/MagicOnion.Generator.Tests.csproj b/tests/MagicOnion.Generator.Tests/MagicOnion.Generator.Tests.csproj deleted file mode 100644 index ac15b492f..000000000 --- a/tests/MagicOnion.Generator.Tests/MagicOnion.Generator.Tests.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - net7.0 - enable - latest - false - - true - ..\..\src\MagicOnion\opensource.snk - - - - - - - - - - - - - - - - From 91aa8314600837f26a9ed3216e29ae81463f3842 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 17:11:08 +0900 Subject: [PATCH 21/66] Move from T4 template to StringWriter-based template --- .../CodeGen/EnumTemplate.cs | 329 ------------------ .../CodeGen/EnumTemplate.tt | 39 --- .../MessagePackEnumFormatterGenerator.cs | 58 +++ .../MagicOnion.Client.SourceGenerator.csproj | 10 - .../MagicOnionCompiler.cs | 6 +- 5 files changed, 59 insertions(+), 383 deletions(-) delete mode 100644 src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs delete mode 100644 src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt create mode 100644 src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs deleted file mode 100644 index 9ec95eb39..000000000 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.cs +++ /dev/null @@ -1,329 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version: 17.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -namespace MagicOnion.Client.SourceGenerator.CodeGen -{ - using System.Linq; - using System.Text; - using System.Collections.Generic; - using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; - using System; - - /// - /// Class to produce the template output - /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] - public partial class EnumTemplate : EnumTemplateBase - { - /// - /// Create the template output - /// - public virtual string TransformText() - { - this.Write("#pragma warning disable 618\r\n#pragma warning disable 612\r\n#pragma warning disable" + - " 414\r\n#pragma warning disable 219\r\n#pragma warning disable 168\r\n\r\nnamespace "); - this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n using System;\r\n using MessagePack;\r\n\r\n"); - foreach (var info in EnumSerializationInfos) { - this.Write(" public sealed class "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FormatterName)); - this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); - this.Write(">\r\n {\r\n public void Serialize(ref MessagePackWriter writer, "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); - this.Write(" value, MessagePackSerializerOptions options)\r\n {\r\n writer.Writ" + - "e(("); - this.Write(this.ToStringHelper.ToStringWithCulture(info.UnderlyingType)); - this.Write(")value);\r\n }\r\n \r\n public "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); - this.Write(" Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)\r" + - "\n {\r\n return ("); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); - this.Write(")reader.Read"); - this.Write(this.ToStringHelper.ToStringWithCulture(info.UnderlyingType)); - this.Write("();\r\n }\r\n }\r\n"); - } - this.Write("\r\n}\r\n\r\n#pragma warning restore 168\r\n#pragma warning restore 219\r\n#pragma warning " + - "restore 414\r\n#pragma warning restore 612\r\n#pragma warning restore 618\r\n"); - return this.GenerationEnvironment.ToString(); - } - } - #region Base class - /// - /// Base class for this transformation - /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] - public class EnumTemplateBase - { - #region Fields - private global::System.Text.StringBuilder generationEnvironmentField; - private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; - private global::System.Collections.Generic.List indentLengthsField; - private string currentIndentField = ""; - private bool endsWithNewline; - private global::System.Collections.Generic.IDictionary sessionField; - #endregion - #region Properties - /// - /// The string builder that generation-time code is using to assemble generated output - /// - public System.Text.StringBuilder GenerationEnvironment - { - get - { - if ((this.generationEnvironmentField == null)) - { - this.generationEnvironmentField = new global::System.Text.StringBuilder(); - } - return this.generationEnvironmentField; - } - set - { - this.generationEnvironmentField = value; - } - } - /// - /// The error collection for the generation process - /// - public System.CodeDom.Compiler.CompilerErrorCollection Errors - { - get - { - if ((this.errorsField == null)) - { - this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); - } - return this.errorsField; - } - } - /// - /// A list of the lengths of each indent that was added with PushIndent - /// - private System.Collections.Generic.List indentLengths - { - get - { - if ((this.indentLengthsField == null)) - { - this.indentLengthsField = new global::System.Collections.Generic.List(); - } - return this.indentLengthsField; - } - } - /// - /// Gets the current indent we use when adding lines to the output - /// - public string CurrentIndent - { - get - { - return this.currentIndentField; - } - } - /// - /// Current transformation session - /// - public virtual global::System.Collections.Generic.IDictionary Session - { - get - { - return this.sessionField; - } - set - { - this.sessionField = value; - } - } - #endregion - #region Transform-time helpers - /// - /// Write text directly into the generated output - /// - public void Write(string textToAppend) - { - if (string.IsNullOrEmpty(textToAppend)) - { - return; - } - // If we're starting off, or if the previous text ended with a newline, - // we have to append the current indent first. - if (((this.GenerationEnvironment.Length == 0) - || this.endsWithNewline)) - { - this.GenerationEnvironment.Append(this.currentIndentField); - this.endsWithNewline = false; - } - // Check if the current text ends with a newline - if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) - { - this.endsWithNewline = true; - } - // This is an optimization. If the current indent is "", then we don't have to do any - // of the more complex stuff further down. - if ((this.currentIndentField.Length == 0)) - { - this.GenerationEnvironment.Append(textToAppend); - return; - } - // Everywhere there is a newline in the text, add an indent after it - textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); - // If the text ends with a newline, then we should strip off the indent added at the very end - // because the appropriate indent will be added when the next time Write() is called - if (this.endsWithNewline) - { - this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); - } - else - { - this.GenerationEnvironment.Append(textToAppend); - } - } - /// - /// Write text directly into the generated output - /// - public void WriteLine(string textToAppend) - { - this.Write(textToAppend); - this.GenerationEnvironment.AppendLine(); - this.endsWithNewline = true; - } - /// - /// Write formatted text directly into the generated output - /// - public void Write(string format, params object[] args) - { - this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); - } - /// - /// Write formatted text directly into the generated output - /// - public void WriteLine(string format, params object[] args) - { - this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); - } - /// - /// Raise an error - /// - public void Error(string message) - { - System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); - error.ErrorText = message; - this.Errors.Add(error); - } - /// - /// Raise a warning - /// - public void Warning(string message) - { - System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); - error.ErrorText = message; - error.IsWarning = true; - this.Errors.Add(error); - } - /// - /// Increase the indent - /// - public void PushIndent(string indent) - { - if ((indent == null)) - { - throw new global::System.ArgumentNullException("indent"); - } - this.currentIndentField = (this.currentIndentField + indent); - this.indentLengths.Add(indent.Length); - } - /// - /// Remove the last indent that was added with PushIndent - /// - public string PopIndent() - { - string returnValue = ""; - if ((this.indentLengths.Count > 0)) - { - int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; - this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); - if ((indentLength > 0)) - { - returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); - this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); - } - } - return returnValue; - } - /// - /// Remove any indentation - /// - public void ClearIndent() - { - this.indentLengths.Clear(); - this.currentIndentField = ""; - } - #endregion - #region ToString Helpers - /// - /// Utility class to produce culture-oriented representation of an object as a string. - /// - public class ToStringInstanceHelper - { - private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; - /// - /// Gets or sets format provider to be used by ToStringWithCulture method. - /// - public System.IFormatProvider FormatProvider - { - get - { - return this.formatProviderField ; - } - set - { - if ((value != null)) - { - this.formatProviderField = value; - } - } - } - /// - /// This is called from the compile/run appdomain to convert objects within an expression block to a string - /// - public string ToStringWithCulture(object objectToConvert) - { - if ((objectToConvert == null)) - { - throw new global::System.ArgumentNullException("objectToConvert"); - } - System.Type t = objectToConvert.GetType(); - System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { - typeof(System.IFormatProvider)}); - if ((method == null)) - { - return objectToConvert.ToString(); - } - else - { - return ((string)(method.Invoke(objectToConvert, new object[] { - this.formatProviderField }))); - } - } - } - private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); - /// - /// Helper to produce culture-oriented representation of an object as a string - /// - public ToStringInstanceHelper ToStringHelper - { - get - { - return this.toStringHelperField; - } - } - #endregion - } - #endregion -} diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt b/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt deleted file mode 100644 index 6921d23b1..000000000 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/EnumTemplate.tt +++ /dev/null @@ -1,39 +0,0 @@ -<#@ template debug="false" hostspecific="false" language="C#" linePragmas="false" #> -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ import namespace="MagicOnion.Client.SourceGenerator.CodeGen.Extensions" #> -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -namespace <#= Namespace #> -{ - using System; - using MessagePack; - -<# foreach (var info in EnumSerializationInfos) { #> - public sealed class <#= info.FormatterName #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= info.FullName #>> - { - public void Serialize(ref MessagePackWriter writer, <#= info.FullName #> value, MessagePackSerializerOptions options) - { - writer.Write((<#= info.UnderlyingType #>)value); - } - - public <#= info.FullName #> Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) - { - return (<#= info.FullName #>)reader.Read<#= info.UnderlyingType #>(); - } - } -<# } #> - -} - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs new file mode 100644 index 000000000..9ef508eb4 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs @@ -0,0 +1,58 @@ +using MagicOnion.Client.SourceGenerator.CodeAnalysis; + +namespace MagicOnion.Client.SourceGenerator.CodeGen; + +internal class MessagePackEnumFormatterGenerator +{ + public static string Build(string @namespace, IEnumerable enumSerializationInfoSet) + { + var writer = new StringWriter(); + writer.WriteLine($$""" + #pragma warning disable 618 + #pragma warning disable 612 + #pragma warning disable 414 + #pragma warning disable 219 + #pragma warning disable 168 + + """); + + writer.WriteLine($$""" + namespace {{@namespace}} + """); + writer.WriteLine($$""" + { + using System; + using MessagePack; + + """); + foreach (var info in enumSerializationInfoSet) + { + writer.WriteLine($$""" + public sealed class {{info.FormatterName}} : global::MessagePack.Formatters.IMessagePackFormatter<{{info.FullName}}> + { + public void Serialize(ref MessagePackWriter writer, {{info.FullName}} value, MessagePackSerializerOptions options) + { + writer.Write(({{info.UnderlyingType}})value); + } + + public {{info.FullName}} Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return ({{info.FullName}})reader.Read{{info.UnderlyingType}}(); + } + } + """); + } + writer.WriteLine($$""" + + } + + #pragma warning restore 168 + #pragma warning restore 219 + #pragma warning restore 414 + #pragma warning restore 612 + #pragma warning restore 618 + """); + + return writer.ToString(); + } +} diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index c1634d5b9..d1afd67a1 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -36,11 +36,6 @@ - - EnumTemplate.tt - True - True - RegisterTemplate.tt True @@ -49,11 +44,6 @@ - - MagicOnion.Client.SourceGenerator.CodeGen - EnumTemplate.cs - TextTemplatingFilePreprocessor - MagicOnion.Client.SourceGenerator.CodeGen RegisterTemplate.cs diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs index 30a65725e..6d0cf6e91 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs @@ -35,11 +35,7 @@ public class MagicOnionCompiler Namespace: namespaceDot + "Resolvers", InitializerName: "MagicOnionResolver", Generator: new MessagePackFormatterResolverGenerator(), - EnumFormatterGenerator: x => new EnumTemplate() - { - Namespace = namespaceDot + "Formatters", - EnumSerializationInfos = x.ToArray() - }.TransformText() + EnumFormatterGenerator: x => MessagePackEnumFormatterGenerator.Build(namespaceDot + "Formatters", x) ), _ => throw new NotImplementedException(), }; From 1098f71c5c8df6fe95ad516971ef588743c057d2 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 17:35:05 +0900 Subject: [PATCH 22/66] Move from T4 template to StringWriter-based template --- .../CodeGen/MagicOnionInitializerGenerator.cs | 139 ++++++ .../CodeGen/RegisterTemplate.cs | 420 ------------------ .../CodeGen/RegisterTemplate.tt | 111 ----- .../CodeGen/TemplatePartials.cs | 17 - .../MagicOnion.Client.SourceGenerator.csproj | 16 - .../MagicOnionCompiler.cs | 11 +- .../GenerateTest.cs | 2 +- .../MagicOnion_MagicOnionInitializer.g.cs | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 0 .../MyApplication1_GreeterServiceClient.g.cs | 0 10 files changed, 141 insertions(+), 575 deletions(-) create mode 100644 src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs delete mode 100644 src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs delete mode 100644 src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt delete mode 100644 src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/{Test1 => Generate}/MagicOnion_MagicOnionInitializer.g.cs (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/{Test1 => Generate}/MagicOnion_Resolvers_MagicOnionResolver.g.cs (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/{Test1 => Generate}/MyApplication1_GreeterServiceClient.g.cs (100%) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs new file mode 100644 index 000000000..08a36de62 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs @@ -0,0 +1,139 @@ +using MagicOnion.Client.SourceGenerator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; + +namespace MagicOnion.Client.SourceGenerator.CodeGen; + +internal class MagicOnionInitializerGenerator +{ + public static string Build(GeneratorOptions options, MagicOnionServiceCollection serviceCollection) + { + var writer = new StringWriter(); + writer.WriteLine($$""" + #pragma warning disable 618 + #pragma warning disable 612 + #pragma warning disable 414 + #pragma warning disable 219 + #pragma warning disable 168 + + // NOTE: Disable warnings for nullable reference types. + // `#nullable disable` causes compile error on old C# compilers (-7.3) + #pragma warning disable 8603 // Possible null reference return. + #pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. + #pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + + namespace {{options.Namespace}} + { + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + public static partial class MagicOnionInitializer + { + static bool isRegistered = false; + + """); + if (!options.DisableAutoRegister) + { + writer.WriteLine($$""" + #if UNITY_2019_4_OR_NEWER + [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] + #elif NET5_0_OR_GREATER + [System.Runtime.CompilerServices.ModuleInitializer] + #endif + """); + } + writer.WriteLine($$""" + public static void Register() + { + if (isRegistered) return; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + } + } + + public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); + + MagicOnionGeneratedClientFactoryProvider() {} + + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + """); + + foreach (var serviceInfo in serviceCollection.Services) + { + writer.WriteLine($$""" + if (typeof(T) == typeof({{serviceInfo.ServiceType.FullName}})) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate<{{serviceInfo.ServiceType.FullName}}>)((x, y) => new {{serviceInfo.GetClientFullName()}}(x, y))); + } + """); + } + + writer.WriteLine($$""" + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + """); + foreach (var hubInfo in serviceCollection.Hubs) + { + writer.WriteLine($$""" + if (typeof(TStreamingHub) == typeof({{hubInfo.ServiceType.FullName}}) && typeof(TReceiver) == typeof({{hubInfo.Receiver.ReceiverType.FullName}})) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate<{{hubInfo.ServiceType.FullName}}, {{hubInfo.Receiver.ReceiverType.FullName}}>)((a, _, b, c, d, e) => new {{hubInfo.GetClientFullName()}}(a, b, c, d, e))); + } + """); + } + + writer.WriteLine($$""" + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + + } + + #pragma warning restore 168 + #pragma warning restore 219 + #pragma warning restore 414 + #pragma warning restore 612 + #pragma warning restore 618 + """); + + return writer.ToString(); + } +} diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs deleted file mode 100644 index ef8dd7c38..000000000 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.cs +++ /dev/null @@ -1,420 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version: 17.0.0.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ -namespace MagicOnion.Client.SourceGenerator.CodeGen -{ - using System.Linq; - using System.Text; - using System.Collections.Generic; - using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; - using System; - - /// - /// Class to produce the template output - /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] - public partial class RegisterTemplate : RegisterTemplateBase - { - /// - /// Create the template output - /// - public virtual string TransformText() - { - this.Write(@"#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. - -namespace "); - this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write(@" -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -"); - if (!DisableAutoRegisterOnInitialize) { - this.Write("#if UNITY_2019_4_OR_NEWER\r\n [UnityEngine.RuntimeInitializeOnLoadMethod(Uni" + - "tyEngine.RuntimeInitializeLoadType.BeforeSceneLoad)]\r\n#elif NET5_0_OR_GREATER\r\n " + - " [System.Runtime.CompilerServices.ModuleInitializer]\r\n#endif\r\n"); - } - this.Write(" public static void Register()\r\n {\r\n if (isRegistered) r" + - "eturn;\r\n isRegistered = true;\r\n\r\n global::MagicOnion.Clien" + - "t.MagicOnionClientFactoryProvider.Default =\r\n (global::MagicOnion" + - ".Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.Imm" + - "utableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider)\r" + - "\n ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGe" + - "neratedClientFactoryProvider.Instance)\r\n : new global::MagicO" + - "nion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFa" + - "ctoryProvider.Instance);\r\n\r\n global::MagicOnion.Client.StreamingHubCl" + - "ientFactoryProvider.Default =\r\n (global::MagicOnion.Client.Stream" + - "ingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStream" + - "ingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider)\r\n " + - " ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGenerate" + - "dClientFactoryProvider.Instance)\r\n : new global::MagicOnion.C" + - "lient.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactor" + - "yProvider.Instance);\r\n }\r\n }\r\n\r\n public partial class MagicOnionGen" + - "eratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactory" + - "Provider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider\r\n {\r\n " + - " public static MagicOnionGeneratedClientFactoryProvider Instance { get; } " + - "= new MagicOnionGeneratedClientFactoryProvider();\r\n\r\n MagicOnionGenerated" + - "ClientFactoryProvider() {}\r\n\r\n bool global::MagicOnion.Client.IMagicOnion" + - "ClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionC" + - "lientFactoryDelegate factory)\r\n => (factory = MagicOnionClientFact" + - "oryCache.Factory) != null;\r\n\r\n bool global::MagicOnion.Client.IStreami" + - "ngHubClientFactoryProvider.TryGetFactory(out global::M" + - "agicOnion.Client.StreamingHubClientFactoryDelegate fac" + - "tory)\r\n => (factory = StreamingHubClientFactoryCache.Factory) != null;\r\n\r\n static class MagicOnionClientFactoryCache" + - " where T : global::MagicOnion.IService\r\n {\r\n public read" + - "only static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory" + - ";\r\n\r\n static MagicOnionClientFactoryCache()\r\n {\r\n " + - " object factory = default(global::MagicOnion.Client.MagicOnionClientFactor" + - "yDelegate);\r\n\r\n"); - foreach(var serviceInfo in Services) { - this.Write(" if (typeof(T) == typeof("); - this.Write(this.ToStringHelper.ToStringWithCulture(serviceInfo.ServiceType.FullName)); - this.Write("))\r\n {\r\n factory = ((global::MagicOnion.Client." + - "MagicOnionClientFactoryDelegate<"); - this.Write(this.ToStringHelper.ToStringWithCulture(serviceInfo.ServiceType.FullName)); - this.Write(">)((x, y) => new "); - this.Write(this.ToStringHelper.ToStringWithCulture(serviceInfo.GetClientFullName())); - this.Write("(x, y)));\r\n }\r\n"); - } // foreach - this.Write(@" Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - -"); - foreach(var hubInfo in Hubs) { - this.Write(" if (typeof(TStreamingHub) == typeof("); - this.Write(this.ToStringHelper.ToStringWithCulture(hubInfo.ServiceType.FullName)); - this.Write(") && typeof(TReceiver) == typeof("); - this.Write(this.ToStringHelper.ToStringWithCulture(hubInfo.Receiver.ReceiverType.FullName)); - this.Write("))\r\n {\r\n factory = ((global::MagicOnion.Client." + - "StreamingHubClientFactoryDelegate<"); - this.Write(this.ToStringHelper.ToStringWithCulture(hubInfo.ServiceType.FullName)); - this.Write(", "); - this.Write(this.ToStringHelper.ToStringWithCulture(hubInfo.Receiver.ReceiverType.FullName)); - this.Write(">)((a, _, b, c, d, e) => new "); - this.Write(this.ToStringHelper.ToStringWithCulture(hubInfo.GetClientFullName())); - this.Write("(a, b, c, d, e)));\r\n }\r\n"); - } // foreach - this.Write(@" - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 -"); - return this.GenerationEnvironment.ToString(); - } - } - #region Base class - /// - /// Base class for this transformation - /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] - public class RegisterTemplateBase - { - #region Fields - private global::System.Text.StringBuilder generationEnvironmentField; - private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; - private global::System.Collections.Generic.List indentLengthsField; - private string currentIndentField = ""; - private bool endsWithNewline; - private global::System.Collections.Generic.IDictionary sessionField; - #endregion - #region Properties - /// - /// The string builder that generation-time code is using to assemble generated output - /// - public System.Text.StringBuilder GenerationEnvironment - { - get - { - if ((this.generationEnvironmentField == null)) - { - this.generationEnvironmentField = new global::System.Text.StringBuilder(); - } - return this.generationEnvironmentField; - } - set - { - this.generationEnvironmentField = value; - } - } - /// - /// The error collection for the generation process - /// - public System.CodeDom.Compiler.CompilerErrorCollection Errors - { - get - { - if ((this.errorsField == null)) - { - this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); - } - return this.errorsField; - } - } - /// - /// A list of the lengths of each indent that was added with PushIndent - /// - private System.Collections.Generic.List indentLengths - { - get - { - if ((this.indentLengthsField == null)) - { - this.indentLengthsField = new global::System.Collections.Generic.List(); - } - return this.indentLengthsField; - } - } - /// - /// Gets the current indent we use when adding lines to the output - /// - public string CurrentIndent - { - get - { - return this.currentIndentField; - } - } - /// - /// Current transformation session - /// - public virtual global::System.Collections.Generic.IDictionary Session - { - get - { - return this.sessionField; - } - set - { - this.sessionField = value; - } - } - #endregion - #region Transform-time helpers - /// - /// Write text directly into the generated output - /// - public void Write(string textToAppend) - { - if (string.IsNullOrEmpty(textToAppend)) - { - return; - } - // If we're starting off, or if the previous text ended with a newline, - // we have to append the current indent first. - if (((this.GenerationEnvironment.Length == 0) - || this.endsWithNewline)) - { - this.GenerationEnvironment.Append(this.currentIndentField); - this.endsWithNewline = false; - } - // Check if the current text ends with a newline - if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) - { - this.endsWithNewline = true; - } - // This is an optimization. If the current indent is "", then we don't have to do any - // of the more complex stuff further down. - if ((this.currentIndentField.Length == 0)) - { - this.GenerationEnvironment.Append(textToAppend); - return; - } - // Everywhere there is a newline in the text, add an indent after it - textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); - // If the text ends with a newline, then we should strip off the indent added at the very end - // because the appropriate indent will be added when the next time Write() is called - if (this.endsWithNewline) - { - this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); - } - else - { - this.GenerationEnvironment.Append(textToAppend); - } - } - /// - /// Write text directly into the generated output - /// - public void WriteLine(string textToAppend) - { - this.Write(textToAppend); - this.GenerationEnvironment.AppendLine(); - this.endsWithNewline = true; - } - /// - /// Write formatted text directly into the generated output - /// - public void Write(string format, params object[] args) - { - this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); - } - /// - /// Write formatted text directly into the generated output - /// - public void WriteLine(string format, params object[] args) - { - this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); - } - /// - /// Raise an error - /// - public void Error(string message) - { - System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); - error.ErrorText = message; - this.Errors.Add(error); - } - /// - /// Raise a warning - /// - public void Warning(string message) - { - System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); - error.ErrorText = message; - error.IsWarning = true; - this.Errors.Add(error); - } - /// - /// Increase the indent - /// - public void PushIndent(string indent) - { - if ((indent == null)) - { - throw new global::System.ArgumentNullException("indent"); - } - this.currentIndentField = (this.currentIndentField + indent); - this.indentLengths.Add(indent.Length); - } - /// - /// Remove the last indent that was added with PushIndent - /// - public string PopIndent() - { - string returnValue = ""; - if ((this.indentLengths.Count > 0)) - { - int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; - this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); - if ((indentLength > 0)) - { - returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); - this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); - } - } - return returnValue; - } - /// - /// Remove any indentation - /// - public void ClearIndent() - { - this.indentLengths.Clear(); - this.currentIndentField = ""; - } - #endregion - #region ToString Helpers - /// - /// Utility class to produce culture-oriented representation of an object as a string. - /// - public class ToStringInstanceHelper - { - private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; - /// - /// Gets or sets format provider to be used by ToStringWithCulture method. - /// - public System.IFormatProvider FormatProvider - { - get - { - return this.formatProviderField ; - } - set - { - if ((value != null)) - { - this.formatProviderField = value; - } - } - } - /// - /// This is called from the compile/run appdomain to convert objects within an expression block to a string - /// - public string ToStringWithCulture(object objectToConvert) - { - if ((objectToConvert == null)) - { - throw new global::System.ArgumentNullException("objectToConvert"); - } - System.Type t = objectToConvert.GetType(); - System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { - typeof(System.IFormatProvider)}); - if ((method == null)) - { - return objectToConvert.ToString(); - } - else - { - return ((string)(method.Invoke(objectToConvert, new object[] { - this.formatProviderField }))); - } - } - } - private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); - /// - /// Helper to produce culture-oriented representation of an object as a string - /// - public ToStringInstanceHelper ToStringHelper - { - get - { - return this.toStringHelperField; - } - } - #endregion - } - #endregion -} diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt b/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt deleted file mode 100644 index 4c17d6f2b..000000000 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/RegisterTemplate.tt +++ /dev/null @@ -1,111 +0,0 @@ -<#@ template language="C#" linePragmas="false" #> -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ import namespace="MagicOnion.Client.SourceGenerator.CodeGen.Extensions" #> -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. - -namespace <#= Namespace #> -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -<# if (!DisableAutoRegisterOnInitialize) { #> -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif -<# } #> - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - -<# foreach(var serviceInfo in Services) { #> - if (typeof(T) == typeof(<#= serviceInfo.ServiceType.FullName #>)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate<<#= serviceInfo.ServiceType.FullName #>>)((x, y) => new <#= serviceInfo.GetClientFullName() #>(x, y))); - } -<# } // foreach #> - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - -<# foreach(var hubInfo in Hubs) { #> - if (typeof(TStreamingHub) == typeof(<#= hubInfo.ServiceType.FullName #>) && typeof(TReceiver) == typeof(<#= hubInfo.Receiver.ReceiverType.FullName #>)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate<<#= hubInfo.ServiceType.FullName #>, <#= hubInfo.Receiver.ReceiverType.FullName #>>)((a, _, b, c, d, e) => new <#= hubInfo.GetClientFullName() #>(a, b, c, d, e))); - } -<# } // foreach #> - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs deleted file mode 100644 index 0211e990a..000000000 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/TemplatePartials.cs +++ /dev/null @@ -1,17 +0,0 @@ -using MagicOnion.Client.SourceGenerator.CodeAnalysis; - -namespace MagicOnion.Client.SourceGenerator.CodeGen; - -public partial class RegisterTemplate -{ - public string Namespace { get; init; } = default!; - public bool DisableAutoRegisterOnInitialize { get; init; } = default!; - public IReadOnlyList Services { get; init; } = default!; - public IReadOnlyList Hubs { get; init; } = default!; -} - -public partial class EnumTemplate -{ - public string Namespace { get; init; } = default!; - public IReadOnlyList EnumSerializationInfos { get; init; } = default!; -} diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index d1afd67a1..f0febe512 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -35,22 +35,6 @@ - - - RegisterTemplate.tt - True - True - - - - - - MagicOnion.Client.SourceGenerator.CodeGen - RegisterTemplate.cs - TextTemplatingFilePreprocessor - - - diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs index 6d0cf6e91..b02d2bcbc 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs @@ -56,21 +56,12 @@ public class MagicOnionCompiler sw.Restart(); - var registerTemplate = new RegisterTemplate - { - Namespace = options.Namespace, - Services = serviceCollection.Services, - Hubs = serviceCollection.Hubs, - DisableAutoRegisterOnInitialize = options.DisableAutoRegister, - }; - var formatterCodeGenContext = new SerializationFormatterCodeGenContext(serialization.Namespace, namespaceDot + "Formatters", serialization.InitializerName, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); var resolverTexts = serialization.Generator.Build(formatterCodeGenContext); cancellationToken.ThrowIfCancellationRequested(); - - outputs.Add((GeneratePathFromNamespaceAndTypeName(registerTemplate.Namespace, "MagicOnionInitializer"), WithAutoGenerated(registerTemplate.TransformText()))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(options.Namespace, "MagicOnionInitializer"), WithAutoGenerated(MagicOnionInitializerGenerator.Build(options, serviceCollection)))); outputs.Add((GeneratePathFromNamespaceAndTypeName(formatterCodeGenContext.Namespace, formatterCodeGenContext.InitializerName), WithAutoGenerated(resolverTexts))); foreach (var enumSerializationInfo in serializationInfoCollection.Enums) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs index 4d87f43fe..f8610e458 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs @@ -5,7 +5,7 @@ namespace MagicOnion.Client.SourceGenerator.Tests; public class GenerateTest { [Fact] - public async Task Test1() + public async Task Generate() { var source = """ using MagicOnion; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Test1/MyApplication1_GreeterServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs From ef160c1231821f531691e43307b1a46908f1cb84 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 18:08:01 +0900 Subject: [PATCH 23/66] Cleanup generated source codes --- .../CodeGen/MagicOnionInitializerGenerator.cs | 20 +----- ...emoryPackFormatterRegistrationGenerator.cs | 20 +----- .../MessagePackEnumFormatterGenerator.cs | 23 ++----- .../MessagePackFormatterResolverGenerator.cs | 22 ++----- .../StaticMagicOnionClientGenerator.cs | 15 ++--- .../StaticStreamingHubClientGenerator.cs | 15 ++--- .../MagicOnionCompiler.cs | 18 ++--- ...on_Formatters_MyClass_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../HubReceiver/TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../Parameters/TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../Return/TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../Return_Enum/TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../Return/TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../Complex/TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../Return_Task/TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../MyApplication1_GreeterServiceClient.g.cs | 13 +--- ...on_Formatters_ApartmentStateFormatter.g.cs | 23 ++----- ...ters_ClientCertificateOptionFormatter.g.cs | 23 ++----- ...gicOnion_Formatters_FileModeFormatter.g.cs | 23 ++----- ...rmatters_TaskCreationOptionsFormatter.g.cs | 23 ++----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../MyNamespace_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../TempProject_MyHubClient.g.cs | 15 +---- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../MyApplication1_GreeterServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 18 +---- .../MyApplication1_GreeterServiceClient.g.cs | 13 +--- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 20 +----- .../MyApplication1_GreeterServiceClient.g.cs | 13 +--- .../MyApplication1_GreeterServiceClient.g.cs | 13 +--- .../__Generated___MagicOnionInitializer.g.cs | 22 +------ ...erated___Resolvers_MagicOnionResolver.g.cs | 20 +----- .../MagicOnion_MagicOnionInitializer.g.cs | 20 +----- ...MagicOnionMemoryPackFormatterProvider.g.cs | 18 +---- .../MyApplication1_GreeterServiceClient.g.cs | 13 +--- .../RunTest.cs | 65 ++++++++++++++++++- 262 files changed, 714 insertions(+), 3992 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs index 08a36de62..e8f79e159 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs @@ -9,17 +9,9 @@ public static string Build(GeneratorOptions options, MagicOnionServiceCollection { var writer = new StringWriter(); writer.WriteLine($$""" - #pragma warning disable 618 - #pragma warning disable 612 - #pragma warning disable 414 - #pragma warning disable 219 - #pragma warning disable 168 - - // NOTE: Disable warnings for nullable reference types. - // `#nullable disable` causes compile error on old C# compilers (-7.3) - #pragma warning disable 8603 // Possible null reference return. - #pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. - #pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + // + #pragma warning disable CS0618 // 'member' is obsolete: 'text' + #pragma warning disable CS0612 // 'member' is obsolete namespace {{options.Namespace}} { @@ -126,12 +118,6 @@ static StreamingHubClientFactoryCache() } } - - #pragma warning restore 168 - #pragma warning restore 219 - #pragma warning restore 414 - #pragma warning restore 612 - #pragma warning restore 618 """); return writer.ToString(); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs index 745af89cf..709476d0c 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs @@ -16,17 +16,10 @@ public string Build(SerializationFormatterCodeGenContext ctx) static void EmitPreamble(SerializationFormatterCodeGenContext ctx) { ctx.TextWriter.WriteLines(""" - #pragma warning disable 618 - #pragma warning disable 612 - #pragma warning disable 414 - #pragma warning disable 219 - #pragma warning disable 168 + // + #pragma warning disable CS0618 // 'member' is obsolete: 'text' + #pragma warning disable CS0612 // 'member' is obsolete - // NOTE: Disable warnings for nullable reference types. - // `#nullable disable` causes compile error on old C# compilers (-7.3) - #pragma warning disable 8603 // Possible null reference return. - #pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. - #pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. """); } @@ -74,12 +67,5 @@ public static void RegisterFormatters() static void EmitPostscript(SerializationFormatterCodeGenContext ctx) { - ctx.TextWriter.WriteLines(""" - #pragma warning restore 168 - #pragma warning restore 219 - #pragma warning restore 414 - #pragma warning restore 612 - #pragma warning restore 618 - """); } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs index 9ef508eb4..c3ee882f0 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs @@ -8,11 +8,9 @@ public static string Build(string @namespace, IEnumerable { var writer = new StringWriter(); writer.WriteLine($$""" - #pragma warning disable 618 - #pragma warning disable 612 - #pragma warning disable 414 - #pragma warning disable 219 - #pragma warning disable 168 + // + #pragma warning disable CS0618 // 'member' is obsolete: 'text' + #pragma warning disable CS0612 // 'member' is obsolete """); @@ -21,8 +19,8 @@ namespace {{@namespace}} """); writer.WriteLine($$""" { - using System; - using MessagePack; + using global::System; + using global::MessagePack; """); foreach (var info in enumSerializationInfoSet) @@ -30,12 +28,12 @@ namespace {{@namespace}} writer.WriteLine($$""" public sealed class {{info.FormatterName}} : global::MessagePack.Formatters.IMessagePackFormatter<{{info.FullName}}> { - public void Serialize(ref MessagePackWriter writer, {{info.FullName}} value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, {{info.FullName}} value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write(({{info.UnderlyingType}})value); } - public {{info.FullName}} Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public {{info.FullName}} Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return ({{info.FullName}})reader.Read{{info.UnderlyingType}}(); } @@ -43,14 +41,7 @@ public void Serialize(ref MessagePackWriter writer, {{info.FullName}} value, Mes """); } writer.WriteLine($$""" - } - - #pragma warning restore 168 - #pragma warning restore 219 - #pragma warning restore 414 - #pragma warning restore 612 - #pragma warning restore 618 """); return writer.ToString(); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs index 106f8192d..d17d5352f 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs @@ -16,17 +16,10 @@ public string Build(SerializationFormatterCodeGenContext ctx) static void EmitPreamble(SerializationFormatterCodeGenContext ctx) { ctx.TextWriter.WriteLines(""" - #pragma warning disable 618 - #pragma warning disable 612 - #pragma warning disable 414 - #pragma warning disable 219 - #pragma warning disable 168 - - // NOTE: Disable warnings for nullable reference types. - // `#nullable disable` causes compile error on old C# compilers (-7.3) - #pragma warning disable 8603 // Possible null reference return. - #pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. - #pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + // + #pragma warning disable CS0618 // 'member' is obsolete: 'text' + #pragma warning disable CS0612 // 'member' is obsolete + """); } @@ -172,12 +165,5 @@ internal static void Register() } static void EmitPostscript(SerializationFormatterCodeGenContext ctx) { - ctx.TextWriter.WriteLines(""" - #pragma warning restore 168 - #pragma warning restore 219 - #pragma warning restore 414 - #pragma warning restore 612 - #pragma warning restore 618 - """); } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs index 5c20322f0..5030bacdf 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs @@ -42,17 +42,10 @@ public static string Build(IEnumerable services) static void EmitHeader(IndentedTextWriter textWriter) { textWriter.WriteLines(""" - #pragma warning disable 618 - #pragma warning disable 612 - #pragma warning disable 414 - #pragma warning disable 219 - #pragma warning disable 168 - - // NOTE: Disable warnings for nullable reference types. - // `#nullable disable` causes compile error on old C# compilers (-7.3) - #pragma warning disable 8603 // Possible null reference return. - #pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. - #pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + // + #pragma warning disable CS0618 // 'member' is obsolete: 'text' + #pragma warning disable CS0612 // 'member' is obsolete + """); textWriter.WriteLine(); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs index 5bf372d6d..ef0f074a6 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs @@ -42,17 +42,10 @@ public static string Build(IEnumerable hubs) static void EmitHeader(IndentedTextWriter textWriter) { textWriter.WriteLines(""" - #pragma warning disable 618 - #pragma warning disable 612 - #pragma warning disable 414 - #pragma warning disable 219 - #pragma warning disable 168 - - // NOTE: Disable warnings for nullable reference types. - // `#nullable disable` causes compile error on old C# compilers (-7.3) - #pragma warning disable 8603 // Possible null reference return. - #pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. - #pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. + // + #pragma warning disable CS0618 // 'member' is obsolete: 'text' + #pragma warning disable CS0612 // 'member' is obsolete + #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used """); textWriter.WriteLine(); } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs index b02d2bcbc..b709e957d 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs @@ -61,24 +61,24 @@ public class MagicOnionCompiler cancellationToken.ThrowIfCancellationRequested(); - outputs.Add((GeneratePathFromNamespaceAndTypeName(options.Namespace, "MagicOnionInitializer"), WithAutoGenerated(MagicOnionInitializerGenerator.Build(options, serviceCollection)))); - outputs.Add((GeneratePathFromNamespaceAndTypeName(formatterCodeGenContext.Namespace, formatterCodeGenContext.InitializerName), WithAutoGenerated(resolverTexts))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(options.Namespace, "MagicOnionInitializer"), MagicOnionInitializerGenerator.Build(options, serviceCollection))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(formatterCodeGenContext.Namespace, formatterCodeGenContext.InitializerName), resolverTexts)); foreach (var enumSerializationInfo in serializationInfoCollection.Enums) { - outputs.Add((GeneratePathFromNamespaceAndTypeName(namespaceDot + "Formatters", enumSerializationInfo.FormatterName), WithAutoGenerated(serialization.EnumFormatterGenerator(new []{ enumSerializationInfo })))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(namespaceDot + "Formatters", enumSerializationInfo.FormatterName), serialization.EnumFormatterGenerator(new []{ enumSerializationInfo }))); } foreach (var service in serviceCollection.Services) { var x = StaticMagicOnionClientGenerator.Build(new[] { service }); - outputs.Add((GeneratePathFromNamespaceAndTypeName(service.ServiceType.Namespace, service.GetClientName()), WithAutoGenerated(x))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(service.ServiceType.Namespace, service.GetClientName()), x)); } foreach (var hub in serviceCollection.Hubs) { var x = StaticStreamingHubClientGenerator.Build(new [] { hub }); - outputs.Add((GeneratePathFromNamespaceAndTypeName(hub.ServiceType.Namespace, hub.GetClientName()), WithAutoGenerated(x))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(hub.ServiceType.Namespace, hub.GetClientName()), x)); } return outputs.OrderBy(x => x.Path).ToArray(); @@ -88,12 +88,4 @@ static string GeneratePathFromNamespaceAndTypeName(string ns, string className) { return $"{ns}_{className}".Replace(".", "_").Replace("global::", string.Empty) + ".g.cs"; } - - static string WithAutoGenerated(string s) - { - var sb = new StringBuilder(); - sb.AppendLine("// "); - sb.AppendLine(s); - return sb.ToString(); - } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs index 16766cdb6..320fc01bf 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyClass_MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyClass.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyClass.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyClass.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyClass.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyClass.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 149cab4a5..8f331b997 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -80,9 +72,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs index 268d11007..02359575c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs index edebc2067..af5b9d3c3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -77,9 +69,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs index 011d77817..0f688e813 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs index f3e6f648e..d33cddac9 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -80,9 +72,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs index 37921a938..1ce8f0f6b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs index edebc2067..af5b9d3c3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -77,9 +69,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs index 8bf4ff3f4..602149428 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs index f3e6f648e..d33cddac9 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -80,9 +72,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs index 2b3ce59a8..41008508e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 8a0ee8195..06cd0c444 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs index 937d09643..3410c1516 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -79,4 +71,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index cfb871632..3040589d4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs index 2c761ea0b..941335d4d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -97,4 +89,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index afc535ddc..3c79c288a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs index 79569447a..e8a40f985 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -73,4 +65,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 356a451bb..55c37faba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -80,9 +72,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs index f135340b0..4375d60d5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -73,4 +65,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 187188606..c90a79bc7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs index 76ab6935f..171887442 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -79,4 +71,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a131e74f3..cc422489f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs index ada5c5ae8..9eff8cfe6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -73,4 +65,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs index f74a4a02b..08b98f034 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs index 95d405826..091c85867 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -79,4 +71,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20dcaa25a..9291ee858 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -94,9 +86,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs index 7ee80c869..bface7b68 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -85,4 +77,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs index b2be10399..9dc8bd9dd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -81,9 +73,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs index b24daed4e..1268aafbb 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -73,4 +65,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20067d772..d75be3682 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -83,9 +75,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs index 4686c9809..bcd2a61db 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -73,4 +65,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 8a0ee8195..06cd0c444 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs index 61a0ba2f8..1cfcb266e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -81,4 +73,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index cfb871632..3040589d4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs index 98017f888..37d89a229 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -102,4 +94,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index afc535ddc..3c79c288a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs index 3a7306535..58954cf2d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 187188606..c90a79bc7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs index 6da9a56c2..acccfc4ac 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -81,4 +73,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a131e74f3..cc422489f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs index 4593761ef..60235eb04 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs index f74a4a02b..08b98f034 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs index d3e46f7f2..a59c699c9 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -81,4 +73,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20dcaa25a..9291ee858 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -94,9 +86,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs index cd11c78ff..17cf6673c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -88,4 +80,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs index b2be10399..9dc8bd9dd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -81,9 +73,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs index cc77231b9..098ea7c74 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20067d772..d75be3682 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -83,9 +75,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs index 28c32f652..afa8ef522 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 8a0ee8195..06cd0c444 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs index 621a51692..ad9ed2f98 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -81,4 +73,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index cfb871632..3040589d4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs index 34b3ccd62..ab62dec7c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -102,4 +94,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index afc535ddc..3c79c288a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs index f1fd5a574..7828bd3ac 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 356a451bb..55c37faba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -80,9 +72,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs index 060078464..5b629a8db 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 187188606..c90a79bc7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs index 503fa857f..55c577e1f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -81,4 +73,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a131e74f3..cc422489f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs index 555d8a273..bf4d2c3e0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs index f74a4a02b..08b98f034 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs index 20f8a6169..a0a19d7f0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -81,4 +73,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20dcaa25a..9291ee858 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -94,9 +86,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs index 7c0bc927c..cb60efc51 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -88,4 +80,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs index b2be10399..9dc8bd9dd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -81,9 +73,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs index 12306bf64..9e4bff44e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20067d772..d75be3682 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -83,9 +75,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs index 7048bbfc2..6d102ba1f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20bb91d74..aac1cc80c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -113,9 +105,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs index e4a60c342..3b8763340 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -91,4 +83,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 388515710..a151121f3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -88,9 +80,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs index 3df028e78..faab412a3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -59,4 +51,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index cfb871632..3040589d4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs index a25a7b56c..dac960d2c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -67,4 +59,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index afc535ddc..3c79c288a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs index b7aaa46e1..d3a17c098 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 187188606..c90a79bc7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs index 57ef04b35..89e12c353 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -55,4 +47,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a131e74f3..cc422489f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs index 572388ee5..4e55d7e58 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20dcaa25a..9291ee858 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -94,9 +86,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs index e36824126..d7f4a5f9d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -59,4 +51,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs index b2be10399..9dc8bd9dd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -81,9 +73,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs index 15233ae35..5feea19d7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20067d772..d75be3682 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -83,9 +75,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs index 6a1e7e374..9b3d6f6cc 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 8a0ee8195..06cd0c444 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs index 9d9133d18..6b79570ed 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -55,4 +47,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index cfb871632..3040589d4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs index d746391e3..b13d816c0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -67,4 +59,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index afc535ddc..3c79c288a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs index 7e2cc6e02..ba573232a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 356a451bb..55c37faba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -80,9 +72,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs index 018db0046..12ec62dd0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 187188606..c90a79bc7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs index fa330b4df..d1ac7c8c0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -55,4 +47,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a131e74f3..cc422489f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs index f23b1855b..1875b9183 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs index f74a4a02b..08b98f034 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -82,9 +74,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs index dbf2d0158..2974761ae 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -55,4 +47,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20dcaa25a..9291ee858 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -94,9 +86,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs index 2c905e6fb..9d2043b55 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -59,4 +51,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs index b2be10399..9dc8bd9dd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -81,9 +73,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs index 433ca0972..f93aa8d94 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index fc9fa7d0d..3b1f6ec3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::TempProject.MyEnum value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::TempProject.MyEnum Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::TempProject.MyEnum)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 20067d772..d75be3682 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -83,9 +75,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs index 8e054fe7e..131b08552 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 5e0445213..c2daacb80 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs index 46bf03d4f..039a469c4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -59,4 +51,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 5e0445213..c2daacb80 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs index 46bf03d4f..039a469c4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -59,4 +51,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs index f789a1a02..ca33e7945 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -74,9 +66,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs index f0df37b11..ecb3d0ddd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 5e0445213..c2daacb80 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs index 76aa922de..3ea2f6932 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 2b2043c1c..894999b5f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs index 851646aa6..d2cf56797 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 2e9f1f456..c1998924c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs index 5d5e39ec9..cbcc1c6e3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 4c4301714..c46a5679c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -83,9 +75,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs index 55eaade7c..f1e0709e0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -120,4 +112,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 76d1949ae..ac97f6005 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -80,9 +72,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs index a9a5aff6d..57a05b876 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -80,4 +72,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 592c33fe5..a280fe173 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs index 6406f6f7b..aa345b00c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -80,4 +72,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 592c33fe5..a280fe173 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs index c80cee5f8..18343b061 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -80,4 +72,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a8fb9296d..3dd879564 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -80,9 +72,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs index 7af27938a..932ac2f28 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 5e0445213..c2daacb80 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs index 1b038c289..546b8d6f3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs index f789a1a02..ca33e7945 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -74,9 +66,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs index 7f4ba0f66..efa87d329 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 592c33fe5..a280fe173 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs index 059399f4f..6520b27f5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 66c8eca10..9c63814c3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -74,9 +66,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs index 8a3868c1a..f9892f622 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 592c33fe5..a280fe173 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs index 23cbe70b6..879ad4ba4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 66c8eca10..9c63814c3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -74,9 +66,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs index ff276ef5a..3430e3965 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -74,4 +66,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_MagicOnionInitializer.g.cs index d013f540a..73cac74da 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 466082a12..4cda7d97d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -80,9 +72,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs index 6adbc49ec..43d34fc7f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MyApplication1 { @@ -59,4 +51,3 @@ private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs index bd632954b..cfa638bb6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class ApartmentStateFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::System.Threading.ApartmentState value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Threading.ApartmentState value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::System.Threading.ApartmentState Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::System.Threading.ApartmentState Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::System.Threading.ApartmentState)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs index ad23fb208..610f0f117 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class ClientCertificateOptionFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::System.Net.Http.ClientCertificateOption value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Net.Http.ClientCertificateOption value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::System.Net.Http.ClientCertificateOption Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::System.Net.Http.ClientCertificateOption Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::System.Net.Http.ClientCertificateOption)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs index 21621beae..32b5876a2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class FileModeFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::System.IO.FileMode value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.IO.FileMode value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::System.IO.FileMode Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::System.IO.FileMode Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::System.IO.FileMode)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs index 89c80da43..4d0f0c0ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs @@ -1,33 +1,22 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion.Formatters { - using System; - using MessagePack; + using global::System; + using global::MessagePack; public sealed class TaskCreationOptionsFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, global::System.Threading.Tasks.TaskCreationOptions value, MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Threading.Tasks.TaskCreationOptions value, global::MessagePack.MessagePackSerializerOptions options) { writer.Write((Int32)value); } - public global::System.Threading.Tasks.TaskCreationOptions Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public global::System.Threading.Tasks.TaskCreationOptions Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { return (global::System.Threading.Tasks.TaskCreationOptions)reader.ReadInt32(); } } - } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs index 8c8361ed2..ff62233f2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 8dffc94ac..75e0c983e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -97,9 +89,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs index 31b4f6169..6e540472e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MyNamespace { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs index 2c81cbf4f..9e71bfffd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 2b2043c1c..894999b5f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs index 851646aa6..d2cf56797 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace TempProject { @@ -51,4 +43,3 @@ private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.g.cs index d106ad797..66b342050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 2b2043c1c..894999b5f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -75,9 +67,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs index 0e29d59b7..122fa65b6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used namespace TempProject { @@ -80,4 +72,3 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs index d013f540a..73cac74da 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9a2a12c41..43d539ba0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs index 0e3ddaf1f..5ae7df74b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MyApplication1 { @@ -51,4 +43,3 @@ private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs index 0874843fe..564eb38a3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -83,10 +74,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9a2a12c41..43d539ba0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs index 0e3ddaf1f..5ae7df74b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MyApplication1 { @@ -51,4 +43,3 @@ private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs index d013f540a..73cac74da 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 32bea4244..00b1f9b21 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ -// -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion.Resolvers { using global::System; @@ -81,9 +73,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs index b5019d65d..b488d4e47 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MyApplication1 { @@ -51,4 +43,3 @@ private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs index 0e3ddaf1f..5ae7df74b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MyApplication1 { @@ -51,4 +43,3 @@ private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs index d45926cad..8c933227f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ -// -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace __Generated__ { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs index 8f061d2b1..540728d45 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs @@ -1,15 +1,7 @@ -// -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace __Generated__.Resolvers { using global::System; @@ -78,9 +70,3 @@ internal static void Register() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs index d013f540a..73cac74da 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs @@ -1,15 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete namespace MagicOnion { @@ -88,10 +79,3 @@ static StreamingHubClientFactoryCache() } } - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs index 3147aa523..a11d5a669 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MagicOnion { using global::System; @@ -22,9 +14,3 @@ public static void RegisterFormatters() } } } -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs index 0e3ddaf1f..5ae7df74b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs @@ -1,15 +1,7 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. namespace MyApplication1 { @@ -51,4 +43,3 @@ private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs index 99d7895ac..6998c5c17 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs @@ -9,7 +9,7 @@ namespace MagicOnion.Client.SourceGenerator.Tests; public class RunTest { [Fact] - public async Task RunAndGenerate() + public void RunAndGenerate() { var (compilation, semanticModel) = CompilationHelper.Create( """ @@ -36,6 +36,69 @@ public interface IMyService : IService var generatedTrees = driver.GetRunResult().GeneratedTrees; } + [Fact] + public void RunAndGenerate_Service() + { + var (compilation, semanticModel) = CompilationHelper.Create( + """ + using System; + using MagicOnion; + + namespace TempProject; + + public interface IMyService : IService + { + UnaryResult HelloAsync(string name, int age); + UnaryResult HelloNullableAsync(string? name, int? age); + } + """); + var sourceGenerator = new MagicOnionClientSourceGenerator(); + + GeneratorDriver driver = CSharpGeneratorDriver.Create( + generators: new[] { sourceGenerator.AsSourceGenerator() }, + driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true) + ); + + // Run generator and update compilation + driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var newCompilation, out var diagnostics); + + Assert.DoesNotContain(diagnostics, x => x.Severity > DiagnosticSeverity.Info); + } + + [Fact] + public void RunAndGenerate_StreamingHub() + { + var (compilation, semanticModel) = CompilationHelper.Create( + """ + using System; + using System.Threading.Tasks; + using MagicOnion; + + namespace TempProject; + + public interface IMyStreamingHub : IStreamingHub + { + Task HelloAsync(string name, int age); + Task HelloNullableAsync(string? name, int? age); + } + + public interface IMyStreamingHubReceiver + { + } + """); + var sourceGenerator = new MagicOnionClientSourceGenerator(); + + GeneratorDriver driver = CSharpGeneratorDriver.Create( + generators: new[] { sourceGenerator.AsSourceGenerator() }, + driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true) + ); + + // Run generator and update compilation + driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var newCompilation, out var diagnostics); + + Assert.DoesNotContain(diagnostics, x => x.Severity > DiagnosticSeverity.Info); + } + //[Fact] //public async Task UnchangedTest_1() //{ From 7b88aa1ad09704a4db6f97fdda6bc1fdac675071 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 18:20:17 +0900 Subject: [PATCH 24/66] Cleanup --- .../MagicOnionCompiler.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs index b709e957d..0248200c7 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs @@ -1,8 +1,5 @@ -#pragma warning disable CS1998 - using System.Collections.Immutable; using System.Diagnostics; -using System.Text; using MagicOnion.Client.SourceGenerator.CodeAnalysis; using MagicOnion.Client.SourceGenerator.CodeGen; using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; @@ -16,8 +13,10 @@ public class MagicOnionCompiler { var outputs = new List<(string Path, string Source)>(); - // Prepare args + // . var namespaceDot = string.IsNullOrWhiteSpace(options.Namespace) ? string.Empty : options.Namespace + "."; + // .Formatters + var formattersNamespace = namespaceDot + "Formatters"; // Configure serialization (ISerializationFormatterNameMapper Mapper, string Namespace, string InitializerName, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) @@ -35,28 +34,22 @@ public class MagicOnionCompiler Namespace: namespaceDot + "Resolvers", InitializerName: "MagicOnionResolver", Generator: new MessagePackFormatterResolverGenerator(), - EnumFormatterGenerator: x => MessagePackEnumFormatterGenerator.Build(namespaceDot + "Formatters", x) + EnumFormatterGenerator: x => MessagePackEnumFormatterGenerator.Build(formattersNamespace, x) ), _ => throw new NotImplementedException(), }; - var sw = Stopwatch.StartNew(); - - sw.Restart(); var collector = new MethodCollector(cancellationToken); var serviceCollection = collector.Collect(interfaceSymbols, referenceSymbols); cancellationToken.ThrowIfCancellationRequested(); - sw.Restart(); var serializationInfoCollector = new SerializationInfoCollector(serialization.Mapper); var serializationInfoCollection = serializationInfoCollector.Collect(serviceCollection); cancellationToken.ThrowIfCancellationRequested(); - sw.Restart(); - - var formatterCodeGenContext = new SerializationFormatterCodeGenContext(serialization.Namespace, namespaceDot + "Formatters", serialization.InitializerName, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); + var formatterCodeGenContext = new SerializationFormatterCodeGenContext(serialization.Namespace, formattersNamespace, serialization.InitializerName, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); var resolverTexts = serialization.Generator.Build(formatterCodeGenContext); cancellationToken.ThrowIfCancellationRequested(); @@ -66,7 +59,7 @@ public class MagicOnionCompiler foreach (var enumSerializationInfo in serializationInfoCollection.Enums) { - outputs.Add((GeneratePathFromNamespaceAndTypeName(namespaceDot + "Formatters", enumSerializationInfo.FormatterName), serialization.EnumFormatterGenerator(new []{ enumSerializationInfo }))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(formattersNamespace, enumSerializationInfo.FormatterName), serialization.EnumFormatterGenerator(new []{ enumSerializationInfo }))); } foreach (var service in serviceCollection.Services) From 52e1602692bdfd8033017f865f1dc132574def70 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 11 Oct 2023 18:23:14 +0900 Subject: [PATCH 25/66] Rename MagicOnionCompiler -> MagicOnionClientGenerator --- .../MagicOnion.Client.SourceGenerator.Unity.csproj | 2 +- .../MagicOnionClientSourceGenerator.cs | 3 +-- .../{MagicOnionCompiler.cs => MagicOnionClientGenerator.cs} | 5 ++--- .../MagicOnionClientSourceGenerator.cs | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) rename src/MagicOnion.Client.SourceGenerator/{MagicOnionCompiler.cs => MagicOnionClientGenerator.cs} (93%) diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj index 54ed75288..3823e462e 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs index b17a24f56..f42a547c1 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs @@ -19,11 +19,10 @@ public void Execute(GeneratorExecutionContext context) var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); if (ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) { - var compiler = new MagicOnionCompiler(); var interfaceSymbols = syntaxReceiver.Candidates .Select(x => (INamedTypeSymbol)context.Compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!) .ToImmutableArray(); - var outputs = compiler.Generate(interfaceSymbols, referenceSymbols, options, context.CancellationToken); + var outputs = MagicOnionClientGenerator.Generate(interfaceSymbols, referenceSymbols, options, context.CancellationToken); foreach (var output in outputs) { context.AddSource(output.Path, output.Source); diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs similarity index 93% rename from src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs rename to src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs index 0248200c7..2e1bfeac9 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionCompiler.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs @@ -1,5 +1,4 @@ using System.Collections.Immutable; -using System.Diagnostics; using MagicOnion.Client.SourceGenerator.CodeAnalysis; using MagicOnion.Client.SourceGenerator.CodeGen; using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; @@ -7,9 +6,9 @@ namespace MagicOnion.Client.SourceGenerator; -public class MagicOnionCompiler +public static class MagicOnionClientGenerator { - public IReadOnlyList<(string Path, string Source)> Generate(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, GeneratorOptions options, CancellationToken cancellationToken) + public static IReadOnlyList<(string Path, string Source)> Generate(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, GeneratorOptions options, CancellationToken cancellationToken) { var outputs = new List<(string Path, string Source)>(); diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 8a218bada..c353d7863 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -33,9 +33,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context) var (((options, interfaces), referenceSymbols), compilation) = values; if (referenceSymbols is null) return; - var compiler = new MagicOnionCompiler(); var symbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); - var generated = compiler.Generate(symbols, referenceSymbols, options, sourceProductionContext.CancellationToken); + var generated = MagicOnionClientGenerator.Generate(symbols, referenceSymbols, options, sourceProductionContext.CancellationToken); foreach (var (path, source) in generated) { sourceProductionContext.AddSource(path, source); From 2fc3833c9f18678cca88b9c482adc819f70b7767 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 12 Oct 2023 11:41:24 +0900 Subject: [PATCH 26/66] Remove unused code --- .../Utils/RoslynExtensions.cs | 112 ------------------ 1 file changed, 112 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs index ec077e575..e780ed2e6 100644 --- a/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs @@ -1,128 +1,16 @@ using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; namespace MagicOnion.Client.SourceGenerator.Utils; // Utility and Extension methods for Roslyn internal static class RoslynExtensions { - public static IEnumerable GetNamedTypeSymbols(this Compilation compilation) - { - foreach (var syntaxTree in compilation.SyntaxTrees) - { - var semModel = compilation.GetSemanticModel(syntaxTree); - - foreach (var item in syntaxTree.GetRoot() - .DescendantNodes() - .Select(x => semModel.GetDeclaredSymbol(x)) - .Where(x => x != null)) - { - var namedType = item as INamedTypeSymbol; - if (namedType != null) - { - yield return namedType; - } - } - } - } - - public static IEnumerable EnumerateBaseType(this ITypeSymbol symbol) - { - var t = symbol.BaseType; - while (t != null) - { - yield return t; - t = t.BaseType; - } - } - - public static AttributeData? FindAttribute(this IEnumerable attributeDataList, string typeName) - { - return attributeDataList.FirstOrDefault(x => x.AttributeClass?.ToDisplayString() == typeName); - } - public static AttributeData? FindAttributeShortName(this IEnumerable attributeDataList, string typeName) { return attributeDataList.FirstOrDefault(x => x.AttributeClass?.Name == typeName); } - public static AttributeData? FindAttributeIncludeBasePropertyShortName(this IPropertySymbol property, string typeName) - { - while (true) - { - var data = FindAttributeShortName(property.GetAttributes(), typeName); - if (data != null) return data; - if (property.OverriddenProperty is null) - { - break; - } - property = property.OverriddenProperty; - } - - return null; - } - - public static AttributeSyntax? FindAttribute(this BaseTypeDeclarationSyntax typeDeclaration, SemanticModel model, string typeName) - { - return typeDeclaration.AttributeLists - .SelectMany(x => x.Attributes) - .Where(x => model.GetTypeInfo(x).Type?.ToDisplayString() == typeName) - .FirstOrDefault(); - } - - public static INamedTypeSymbol? FindBaseTargetType(this ITypeSymbol symbol, string typeName) - { - return symbol.EnumerateBaseType() - .Where(x => x.OriginalDefinition?.ToDisplayString() == typeName) - .FirstOrDefault(); - } - - public static object? GetSingleNamedArgumentValue(this AttributeData attribute, string key) - { - foreach (var item in attribute.NamedArguments) - { - if (item.Key == key) - { - return item.Value.Value; - } - } - - return null; - } - - public static bool IsNullable(this INamedTypeSymbol symbol) - { - if (symbol.IsGenericType) - { - if (symbol.ConstructUnboundGenericType().ToDisplayString() == "T?") - { - return true; - } - } - return false; - } - - public static IEnumerable GetAllMembers(this ITypeSymbol symbol) - { - var t = symbol; - while (t != null) - { - foreach (var item in t.GetMembers()) - { - yield return item; - } - t = t.BaseType; - } - } - - public static IEnumerable GetAllInterfaceMembers(this ITypeSymbol symbol) - { - return symbol.GetMembers() - .Concat(symbol.AllInterfaces.SelectMany(x => x.GetMembers())); - } - public static bool ApproximatelyEqual(this ITypeSymbol left, ITypeSymbol right) { if (left == null && right == null) return true; From d29372f27746926423538f06a4652cda095edc8c Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 12 Oct 2023 12:02:05 +0900 Subject: [PATCH 27/66] Refactor --- .../MagicOnionClientSourceGenerator.cs | 8 +++-- .../CodeAnalysis/MethodCollector.cs | 33 +++++++++---------- .../Internal/SyntaxHelper.cs | 3 +- .../MagicOnionClientGenerator.cs | 5 +-- .../MagicOnionClientSourceGenerator.cs | 10 +++--- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs index f42a547c1..93e7e97e3 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs @@ -22,10 +22,12 @@ public void Execute(GeneratorExecutionContext context) var interfaceSymbols = syntaxReceiver.Candidates .Select(x => (INamedTypeSymbol)context.Compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!) .ToImmutableArray(); - var outputs = MagicOnionClientGenerator.Generate(interfaceSymbols, referenceSymbols, options, context.CancellationToken); - foreach (var output in outputs) + var serviceCollection = MethodCollector.Collect(interfaceSymbols, referenceSymbols, context.CancellationToken); + var generated = MagicOnionClientGenerator.Generate(serviceCollection, options, context.CancellationToken); + + foreach (var (path, source) in generated) { - context.AddSource(output.Path, output.Source); + context.AddSource(path, source); } } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index c5f1418a6..9dbad1db1 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -1,4 +1,5 @@ using System.Collections.Immutable; +using System.Threading; using MagicOnion.Client.SourceGenerator.Internal; using MagicOnion.Client.SourceGenerator.Utils; using Microsoft.CodeAnalysis; @@ -10,25 +11,20 @@ namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; /// public class MethodCollector { - readonly CancellationToken cancellationToken; - - public MethodCollector(CancellationToken cancellationToken = default) - { - this.cancellationToken = cancellationToken; - } - - public MagicOnionServiceCollection Collect(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) + public static MagicOnionServiceCollection Collect(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, CancellationToken cancellationToken) { - var ctx = MethodCollectorContext.CreateFromInterfaceSymbols(interfaceSymbols, referenceSymbols); + var ctx = MethodCollectorContext.CreateFromInterfaceSymbols(interfaceSymbols, referenceSymbols, cancellationToken); - return new MagicOnionServiceCollection(GetStreamingHubs(ctx), GetServices(ctx)); + return new MagicOnionServiceCollection(GetStreamingHubs(ctx, cancellationToken), GetServices(ctx, cancellationToken)); } - IReadOnlyList GetStreamingHubs(MethodCollectorContext ctx) + static IReadOnlyList GetStreamingHubs(MethodCollectorContext ctx, CancellationToken cancellationToken) { return ctx.HubInterfaces .Select(x => { + cancellationToken.ThrowIfCancellationRequested(); + var serviceType = MagicOnionTypeInfo.CreateFromSymbol(x); var hasIgnore = HasIgnoreAttribute(x); if (hasIgnore) @@ -72,7 +68,7 @@ static int GetHubMethodIdFromMethodSymbol(IMethodSymbol methodSymbol) static bool HasIgnoreAttribute(ISymbol symbol) => symbol.GetAttributes().FindAttributeShortName("IgnoreAttribute") is not null; - MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, IMethodSymbol methodSymbol) + static MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, IMethodSymbol methodSymbol) { var hubId = GetHubMethodIdFromMethodSymbol(methodSymbol); var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); @@ -102,7 +98,7 @@ MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubMethodInfoFromMethod responseType ); } - MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubReceiverMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, MagicOnionTypeInfo receiverType, IMethodSymbol methodSymbol) + static MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubReceiverMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, MagicOnionTypeInfo receiverType, IMethodSymbol methodSymbol) { var hubId = GetHubMethodIdFromMethodSymbol(methodSymbol); var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); @@ -123,12 +119,13 @@ MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubReceiverMethodInfoFr responseType ); } - - IReadOnlyList GetServices(MethodCollectorContext ctx) + static IReadOnlyList GetServices(MethodCollectorContext ctx, CancellationToken cancellationToken) { return ctx.ServiceInterfaces .Select(x => { + cancellationToken.ThrowIfCancellationRequested(); + var serviceType = MagicOnionTypeInfo.CreateFromSymbol(x); var hasIgnore = HasIgnoreAttribute(x); if (hasIgnore) @@ -158,7 +155,7 @@ IReadOnlyList GetServices(MethodCollectorContext ctx) .ToArray(); } - MagicOnionServiceInfo.MagicOnionServiceMethodInfo CreateServiceMethodInfoFromMethodSymbol(MagicOnionTypeInfo serviceType, IMethodSymbol methodSymbol) + static MagicOnionServiceInfo.MagicOnionServiceMethodInfo CreateServiceMethodInfoFromMethodSymbol(MagicOnionTypeInfo serviceType, IMethodSymbol methodSymbol) { var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); var methodParameters = CreateParameterInfoListFromMethodSymbol(methodSymbol); @@ -273,8 +270,10 @@ public MethodCollectorContext(ReferenceSymbols referenceSymbols, IReadOnlyList interfaceSymbols, ReferenceSymbols referenceSymbols) + public static MethodCollectorContext CreateFromInterfaceSymbols(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var serviceAndHubInterfaces = interfaceSymbols .Where(x => x.TypeKind == TypeKind.Interface) .Where(x => diff --git a/src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs b/src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs index e72a77939..fd676c16d 100644 --- a/src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs +++ b/src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs @@ -6,6 +6,7 @@ namespace MagicOnion.Client.SourceGenerator.Internal; internal static class SyntaxHelper { public static bool IsCandidateInterface(SyntaxNode node) - => node is InterfaceDeclarationSyntax interfaceDeclaration && (interfaceDeclaration.BaseList?.Types.Any() ?? false); + => node is InterfaceDeclarationSyntax interfaceDeclaration && + (interfaceDeclaration.BaseList?.Types.Any() ?? false); } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs index 2e1bfeac9..8338e2fa0 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs @@ -8,7 +8,7 @@ namespace MagicOnion.Client.SourceGenerator; public static class MagicOnionClientGenerator { - public static IReadOnlyList<(string Path, string Source)> Generate(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, GeneratorOptions options, CancellationToken cancellationToken) + public static IReadOnlyList<(string Path, string Source)> Generate(MagicOnionServiceCollection serviceCollection, GeneratorOptions options, CancellationToken cancellationToken) { var outputs = new List<(string Path, string Source)>(); @@ -38,9 +38,6 @@ public static class MagicOnionClientGenerator _ => throw new NotImplementedException(), }; - var collector = new MethodCollector(cancellationToken); - var serviceCollection = collector.Collect(interfaceSymbols, referenceSymbols); - cancellationToken.ThrowIfCancellationRequested(); var serializationInfoCollector = new SerializationInfoCollector(serialization.Mapper); diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index c353d7863..79abf21ee 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -17,8 +17,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context) .Select(static (x, cancellationToken) => ReferenceSymbols.TryCreate(x, out var rs) ? rs : default) .WithTrackingName("mo_ReferenceSymbols"); var interfaces = context.SyntaxProvider.CreateSyntaxProvider( - predicate: (node, ct) => SyntaxHelper.IsCandidateInterface(node), - transform: (ctx, ct) => ctx.Node) + predicate: static (node, ct) => SyntaxHelper.IsCandidateInterface(node), + transform: static (ctx, ct) => ctx.Node) .Collect() .WithTrackingName("mo_Interfaces"); @@ -33,8 +33,10 @@ public void Initialize(IncrementalGeneratorInitializationContext context) var (((options, interfaces), referenceSymbols), compilation) = values; if (referenceSymbols is null) return; - var symbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); - var generated = MagicOnionClientGenerator.Generate(symbols, referenceSymbols, options, sourceProductionContext.CancellationToken); + var interfaceSymbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); + var serviceCollection = MethodCollector.Collect(interfaceSymbols, referenceSymbols, sourceProductionContext.CancellationToken); + var generated = MagicOnionClientGenerator.Generate(serviceCollection, options, sourceProductionContext.CancellationToken); + foreach (var (path, source) in generated) { sourceProductionContext.AddSource(path, source); From 037c675d2b3606fd2ddb23de47e234c5916951f9 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 12 Oct 2023 12:03:01 +0900 Subject: [PATCH 28/66] Rename MagicOnionClientSourceGeneratorRoslyn3 -> MagicOnionClientSourceGenerator --- ...urceGenerator.cs => MagicOnionClientSourceGeneratorRoslyn3.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/MagicOnion.Client.SourceGenerator.Unity/{MagicOnionClientSourceGenerator.cs => MagicOnionClientSourceGeneratorRoslyn3.cs} (100%) diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGeneratorRoslyn3.cs similarity index 100% rename from src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.cs rename to src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGeneratorRoslyn3.cs From 02698fe7e8a9bc1176a632727d4410c9bd9f1227 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 12 Oct 2023 12:24:56 +0900 Subject: [PATCH 29/66] More efficient interface collection --- .../CodeAnalysis/MethodCollector.cs | 67 +++++++------------ 1 file changed, 25 insertions(+), 42 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index 9dbad1db1..f8983752a 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -232,62 +232,45 @@ static MagicOnionTypeInfo CreateRequestTypeFromMethodParameters(IReadOnlyList x.Type).ToArray()); - class MethodCollectorContext + record MethodCollectorContext { - public ReferenceSymbols ReferenceSymbols { get; } - public IReadOnlyList ServiceAndHubInterfaces { get; } - public IReadOnlyList ServiceInterfaces { get; } - public IReadOnlyList HubInterfaces { get; } + public required ReferenceSymbols ReferenceSymbols { get; init; } + public required IReadOnlyList ServiceInterfaces { get; init; } + public required IReadOnlyList HubInterfaces { get; init; } - public MethodCollectorContext(ReferenceSymbols referenceSymbols, IReadOnlyList serviceAndHubInterfaces) + public static MethodCollectorContext CreateFromInterfaceSymbols(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, CancellationToken cancellationToken) { - ReferenceSymbols = referenceSymbols; - ServiceAndHubInterfaces = serviceAndHubInterfaces; - var serviceInterfaces = new HashSet(SymbolEqualityComparer.Default); var hubInterfaces = new HashSet(SymbolEqualityComparer.Default); - foreach (var type in serviceAndHubInterfaces) + + foreach (var interfaceSymbol in interfaceSymbols) { - if (type.AllInterfaces.Any(y => y.ApproximatelyEqual(referenceSymbols.IStreamingHubMarker))) + cancellationToken.ThrowIfCancellationRequested(); + + foreach (var implInterfaceSymbol in interfaceSymbol.AllInterfaces) { - // StreamingHub - if (!type.ConstructedFrom.ApproximatelyEqual(referenceSymbols.IStreamingHub)) + if (implInterfaceSymbol.ApproximatelyEqual(referenceSymbols.IStreamingHubMarker) && + !interfaceSymbol.ConstructedFrom.ApproximatelyEqual(referenceSymbols.IStreamingHub)) { - hubInterfaces.Add(type); + // StreamingHub + hubInterfaces.Add(interfaceSymbol); } - } - else if (type.AllInterfaces.Any(y => y.ApproximatelyEqual(referenceSymbols.IServiceMarker))) - { - // Service - if (!type.ConstructedFrom.ApproximatelyEqual(referenceSymbols.IService)) + else if (implInterfaceSymbol.ApproximatelyEqual(referenceSymbols.IServiceMarker) && + !interfaceSymbol.ConstructedFrom.ApproximatelyEqual(referenceSymbols.IService) && + !hubInterfaces.Contains(interfaceSymbol) /* IStreamingHub also implements IService */) { - serviceInterfaces.Add(type); + // Service + serviceInterfaces.Add(interfaceSymbol); } } } - ServiceInterfaces = serviceInterfaces.ToArray(); - HubInterfaces = hubInterfaces.ToArray(); - } - - public static MethodCollectorContext CreateFromInterfaceSymbols(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - - var serviceAndHubInterfaces = interfaceSymbols - .Where(x => x.TypeKind == TypeKind.Interface) - .Where(x => - { - var all = x.AllInterfaces; - if (all.Any(y => y.ApproximatelyEqual(referenceSymbols.IServiceMarker)) || all.Any(y => y.ApproximatelyEqual(referenceSymbols.IStreamingHubMarker))) - { - return true; - } - return false; - }) - .ToArray(); - - return new MethodCollectorContext(referenceSymbols, serviceAndHubInterfaces); + return new MethodCollectorContext + { + HubInterfaces = hubInterfaces.ToArray(), + ServiceInterfaces = serviceInterfaces.ToArray(), + ReferenceSymbols = referenceSymbols, + }; } } } From 991129ef2a1fd997819a9ddd0cb7b65f3c25a923 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 12 Oct 2023 18:29:41 +0900 Subject: [PATCH 30/66] Report errors as diagnostics --- .../MagicOnionClientSourceGeneratorRoslyn3.cs | 6 +- .../MagicOnionDiagnosticDescriptors.cs | 66 ++++++++ .../CodeAnalysis/MethodCollector.cs | 143 +++++++++++++----- .../MagicOnionClientSourceGenerator.cs | 6 +- .../GenerateServiceTest.cs | 54 +++++-- .../GenerateStreamingHubTest.cs | 65 +++++--- .../MagicOnionSourceGeneratorVerifier.cs | 21 ++- 7 files changed, 284 insertions(+), 77 deletions(-) create mode 100644 src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGeneratorRoslyn3.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGeneratorRoslyn3.cs index 93e7e97e3..929fb5629 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGeneratorRoslyn3.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGeneratorRoslyn3.cs @@ -22,9 +22,13 @@ public void Execute(GeneratorExecutionContext context) var interfaceSymbols = syntaxReceiver.Candidates .Select(x => (INamedTypeSymbol)context.Compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!) .ToImmutableArray(); - var serviceCollection = MethodCollector.Collect(interfaceSymbols, referenceSymbols, context.CancellationToken); + var (serviceCollection, diagnostics) = MethodCollector.Collect(interfaceSymbols, referenceSymbols, context.CancellationToken); var generated = MagicOnionClientGenerator.Generate(serviceCollection, options, context.CancellationToken); + foreach (var diagnostic in diagnostics) + { + context.ReportDiagnostic(diagnostic); + } foreach (var (path, source) in generated) { context.AddSource(path, source); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs new file mode 100644 index 000000000..74f67988f --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs @@ -0,0 +1,66 @@ +using Microsoft.CodeAnalysis; + +namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; + +public static class MagicOnionDiagnosticDescriptors +{ + public static readonly DiagnosticDescriptor StreamingHubUnsupportedReceiverMethodReturnType = + new DiagnosticDescriptor( + id: "MOC1001", + title: "Must be void", + messageFormat: "StreamingHub receiver method '{0}' has unsupported return type '{1}'", + category: "Usage", + description: "The StreamingHub receiver method has unsupported return type.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true); + + public static readonly DiagnosticDescriptor StreamingHubUnsupportedMethodReturnType = + new DiagnosticDescriptor( + id: "MOC1002", + title: "Must be Task or ValueTask", + messageFormat: "StreamingHub method '{0}' has unsupported return type '{1}'", + category: "Usage", + description: "The StreamingHub method has unsupported return type.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true); + + public static readonly DiagnosticDescriptor ServiceUnsupportedMethodReturnType = + new DiagnosticDescriptor( + id: "MOC1003", + title: "Must be UnaryResult or Task of StreamingResult", + messageFormat: "Unsupported return type '{0}' ({1}). Allowed return types are UnaryResult and Task of StreamingResult", + category: "Usage", + description: "The service method has unsupported return type.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true); + + public static readonly DiagnosticDescriptor UnaryUnsupportedMethodReturnType = + new DiagnosticDescriptor( + id: "MOC1004", + title: "Must be non-StreamingResult", + messageFormat: "Unary methods can not return '{0}' ({1})", + category: "Usage", + description: "The Unary method has unsupported return type.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true); + + public static readonly DiagnosticDescriptor StreamingMethodMustHaveNoParameters = + new DiagnosticDescriptor( + id: "MOC1005", + title: "ClientStreaming and DuplexStreaming must be no parameters", + messageFormat: "ClientStreaming and DuplexStreaming must have no parameters ({0})", + category: "Usage", + description: "ClientStreaming and DuplexStreaming must be no parameters.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true); + + public static readonly DiagnosticDescriptor MessagePackArrayRankLimitation = + new DiagnosticDescriptor( + id: "MOC1006", + title: "Must be less than 5", + messageFormat: "An array of rank must be less than 5 ({0})", + category: "Usage", + description: "An array of rank must be less than 5.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true); +} diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index f8983752a..32effe38d 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -1,4 +1,5 @@ using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; using System.Threading; using MagicOnion.Client.SourceGenerator.Internal; using MagicOnion.Client.SourceGenerator.Utils; @@ -11,11 +12,11 @@ namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; /// public class MethodCollector { - public static MagicOnionServiceCollection Collect(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, CancellationToken cancellationToken) + public static (MagicOnionServiceCollection ServiceCollection, IReadOnlyList Diagnostics) Collect(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, CancellationToken cancellationToken) { var ctx = MethodCollectorContext.CreateFromInterfaceSymbols(interfaceSymbols, referenceSymbols, cancellationToken); - return new MagicOnionServiceCollection(GetStreamingHubs(ctx, cancellationToken), GetServices(ctx, cancellationToken)); + return (new MagicOnionServiceCollection(GetStreamingHubs(ctx, cancellationToken), GetServices(ctx, cancellationToken)), ctx.ReportDiagnostics); } static IReadOnlyList GetStreamingHubs(MethodCollectorContext ctx, CancellationToken cancellationToken) @@ -32,26 +33,51 @@ static IReadOnlyList GetStreamingHubs(MethodCollecto return null; } - var methods = x.GetMembers() - .OfType() - .Select(symbol => + var hasError = false; + var methods = new List(); + foreach (var methodSymbol in x.GetMembers().OfType()) + { + if (HasIgnoreAttribute(methodSymbol)) continue; + if (TryCreateHubMethodInfoFromMethodSymbol(serviceType, methodSymbol, out var methodInfo, out var diagnostic)) + { + methods.Add(methodInfo); + } + + if (diagnostic is not null) { - if (HasIgnoreAttribute(symbol)) + ctx.ReportDiagnostics.Add(diagnostic); + if (diagnostic.Severity == DiagnosticSeverity.Error) { - return null; + hasError = true; } - return CreateHubMethodInfoFromMethodSymbol(serviceType, symbol); - }) - .Where(x => x is not null) - .Cast() - .ToArray(); + } + } var receiverInterfaceSymbol = x.AllInterfaces.First(y => y.ConstructedFrom.ApproximatelyEqual(ctx.ReferenceSymbols.IStreamingHub)).TypeArguments[1]; var receiverType = MagicOnionTypeInfo.CreateFromSymbol(receiverInterfaceSymbol); - var receiverMethods = receiverInterfaceSymbol.GetMembers() - .OfType() - .Select(y => CreateHubReceiverMethodInfoFromMethodSymbol(serviceType, receiverType, y)) - .ToArray(); + + var receiverMethods = new List(); + foreach (var methodSymbol in receiverInterfaceSymbol.GetMembers().OfType()) + { + if (TryCreateHubReceiverMethodInfoFromMethodSymbol(serviceType, receiverType, methodSymbol, out var methodInfo, out var diagnostic)) + { + receiverMethods.Add(methodInfo); + } + + if (diagnostic is not null) + { + ctx.ReportDiagnostics.Add(diagnostic); + if (diagnostic.Severity == DiagnosticSeverity.Error) + { + hasError = true; + } + } + } + + if (hasError) + { + return null; + } var receiver = new MagicOnionStreamingHubInfo.MagicOnionStreamingHubReceiverInfo(receiverType, receiverMethods); @@ -68,7 +94,7 @@ static int GetHubMethodIdFromMethodSymbol(IMethodSymbol methodSymbol) static bool HasIgnoreAttribute(ISymbol symbol) => symbol.GetAttributes().FindAttributeShortName("IgnoreAttribute") is not null; - static MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, IMethodSymbol methodSymbol) + static bool TryCreateHubMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, IMethodSymbol methodSymbol, [NotNullWhen(true)] out MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo? methodInfo, out Diagnostic? diagnostic) { var hubId = GetHubMethodIdFromMethodSymbol(methodSymbol); var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); @@ -86,10 +112,15 @@ static MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubMethodInfoFro responseType = methodReturnType.GenericArguments[0]; break; default: - throw new InvalidOperationException($"StreamingHub method '{interfaceType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)}.{methodSymbol.Name}' has unsupported return type '{methodReturnType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.FullyQualified)}'."); + methodInfo = null; + diagnostic = Diagnostic.Create( + MagicOnionDiagnosticDescriptors.StreamingHubUnsupportedMethodReturnType, + methodSymbol.Locations.FirstOrDefault(), methodSymbol.Locations, null, + $"{interfaceType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)}.{methodSymbol.Name}", methodReturnType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.FullyQualified)); + return false; } - return new MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo( + methodInfo = new MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo( hubId, methodSymbol.Name, methodParameters, @@ -97,8 +128,10 @@ static MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubMethodInfoFro requestType, responseType ); + diagnostic = null; + return true; } - static MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubReceiverMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, MagicOnionTypeInfo receiverType, IMethodSymbol methodSymbol) + static bool TryCreateHubReceiverMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, MagicOnionTypeInfo receiverType, IMethodSymbol methodSymbol, [NotNullWhen(true)] out MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo? methodInfo, out Diagnostic? diagnostic) { var hubId = GetHubMethodIdFromMethodSymbol(methodSymbol); var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); @@ -107,10 +140,15 @@ static MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubReceiverMetho var responseType = MagicOnionTypeInfo.KnownTypes.MessagePack_Nil; if (methodReturnType != MagicOnionTypeInfo.KnownTypes.System_Void) { - throw new InvalidOperationException($"StreamingHub receiver method '{receiverType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)}.{methodSymbol.Name}' has unsupported return type '{methodReturnType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)}'."); + methodInfo = null; + diagnostic = Diagnostic.Create( + MagicOnionDiagnosticDescriptors.StreamingHubUnsupportedReceiverMethodReturnType, + methodSymbol.Locations.FirstOrDefault(), methodSymbol.Locations, null, + $"{receiverType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)}.{methodSymbol.Name}", methodReturnType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)); + return false; } - return new MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo( + methodInfo = new MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo( hubId, methodSymbol.Name, methodParameters, @@ -118,6 +156,8 @@ static MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo CreateHubReceiverMetho requestType, responseType ); + diagnostic = null; + return true; } static IReadOnlyList GetServices(MethodCollectorContext ctx, CancellationToken cancellationToken) { @@ -133,19 +173,30 @@ static IReadOnlyList GetServices(MethodCollectorContext c return null; } - var methods = x.GetMembers() - .OfType() - .Select(symbol => + var methods = new List(); + var hasError = false; + foreach (var methodSymbol in x.GetMembers().OfType()) + { + if (HasIgnoreAttribute(methodSymbol)) continue; + if (TryCreateServiceMethodInfoFromMethodSymbol(serviceType, methodSymbol, out var methodInfo, out var diagnostic)) { - if (HasIgnoreAttribute(symbol)) + methods.Add(methodInfo); + } + + if (diagnostic is not null) + { + ctx.ReportDiagnostics.Add(diagnostic); + if (diagnostic.Severity == DiagnosticSeverity.Error) { - return null; + hasError = true; } - return CreateServiceMethodInfoFromMethodSymbol(serviceType, symbol); - }) - .Where(x => x is not null) - .Cast() - .ToArray(); + } + } + + if (hasError) + { + return null; + } return new MagicOnionServiceInfo(serviceType, methods); }) @@ -155,7 +206,7 @@ static IReadOnlyList GetServices(MethodCollectorContext c .ToArray(); } - static MagicOnionServiceInfo.MagicOnionServiceMethodInfo CreateServiceMethodInfoFromMethodSymbol(MagicOnionTypeInfo serviceType, IMethodSymbol methodSymbol) + static bool TryCreateServiceMethodInfoFromMethodSymbol(MagicOnionTypeInfo serviceType, IMethodSymbol methodSymbol, [NotNullWhen(true)] out MagicOnionServiceInfo.MagicOnionServiceMethodInfo? serviceMethodInfo, out Diagnostic? diagnostic) { var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); var methodParameters = CreateParameterInfoListFromMethodSymbol(methodSymbol); @@ -199,18 +250,34 @@ static MagicOnionServiceInfo.MagicOnionServiceMethodInfo CreateServiceMethodInfo // Validates if (methodType == MethodType.Other) { - throw new InvalidOperationException($"Unsupported return type '{methodReturnType.FullName}' ({serviceType.FullName}.{methodSymbol.Name})"); + diagnostic = Diagnostic.Create( + MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType, + methodSymbol.Locations.FirstOrDefault(), methodSymbol.Locations, null, + methodReturnType.FullName, $"{serviceType.FullName}.{methodSymbol.Name}"); + serviceMethodInfo = null; + return false; } if (methodType == MethodType.Unary && responseType.Namespace == "MagicOnion" && (responseType.Name is "ClientStreamingResult" or "ServerStreamingResult" or "DuplexStreamingResult")) { - throw new InvalidOperationException($"Unary methods can not return '{responseType.FullName}' ({serviceType.FullName}.{methodSymbol.Name})"); + diagnostic = Diagnostic.Create( + MagicOnionDiagnosticDescriptors.UnaryUnsupportedMethodReturnType, + methodSymbol.Locations.FirstOrDefault(), methodSymbol.Locations, null, + responseType.FullName, $"{serviceType.FullName}.{methodSymbol.Name}"); + serviceMethodInfo = null; + return false; } if ((methodType == MethodType.ClientStreaming || methodType == MethodType.DuplexStreaming) && methodParameters.Any()) { - throw new InvalidOperationException($"ClientStreaming and DuplexStreaming must have no parameters. ({serviceType.FullName}.{methodSymbol.Name})"); + diagnostic = Diagnostic.Create( + MagicOnionDiagnosticDescriptors.StreamingMethodMustHaveNoParameters, + methodSymbol.Locations.FirstOrDefault(), methodSymbol.Locations, null, + $"{serviceType.FullName}.{methodSymbol.Name}"); + serviceMethodInfo = null; + return false; } - return new MagicOnionServiceInfo.MagicOnionServiceMethodInfo( + diagnostic = null; + serviceMethodInfo = new MagicOnionServiceInfo.MagicOnionServiceMethodInfo( methodType, serviceType.Name, methodSymbol.Name, @@ -220,6 +287,7 @@ static MagicOnionServiceInfo.MagicOnionServiceMethodInfo CreateServiceMethodInfo requestType, responseType ); + return true; } static IReadOnlyList CreateParameterInfoListFromMethodSymbol(IMethodSymbol methodSymbol) @@ -237,6 +305,7 @@ record MethodCollectorContext public required ReferenceSymbols ReferenceSymbols { get; init; } public required IReadOnlyList ServiceInterfaces { get; init; } public required IReadOnlyList HubInterfaces { get; init; } + public List ReportDiagnostics { get; } = new(); public static MethodCollectorContext CreateFromInterfaceSymbols(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, CancellationToken cancellationToken) { diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 79abf21ee..806ddaa68 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -34,9 +34,13 @@ public void Initialize(IncrementalGeneratorInitializationContext context) if (referenceSymbols is null) return; var interfaceSymbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); - var serviceCollection = MethodCollector.Collect(interfaceSymbols, referenceSymbols, sourceProductionContext.CancellationToken); + var (serviceCollection, diagnostics) = MethodCollector.Collect(interfaceSymbols, referenceSymbols, sourceProductionContext.CancellationToken); var generated = MagicOnionClientGenerator.Generate(serviceCollection, options, sourceProductionContext.CancellationToken); + foreach (var diagnostic in diagnostics) + { + sourceProductionContext.ReportDiagnostic(diagnostic); + } foreach (var (path, source) in generated) { sourceProductionContext.AddSource(path, source); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs index 9e09c5324..ac9664cf3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs @@ -1,4 +1,7 @@ +using MagicOnion.Client.SourceGenerator.CodeAnalysis; using MagicOnion.Client.SourceGenerator.Tests.Verifiers; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Testing; namespace MagicOnion.Client.SourceGenerator.Tests; @@ -12,7 +15,7 @@ public async Task Return_UnaryResultNonGeneric() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyService : IService @@ -33,7 +36,7 @@ public async Task Return_UnaryResultOfT() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyService : IService @@ -54,7 +57,7 @@ public async Task Return_UnaryResultOfValueType() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyService : IService @@ -75,7 +78,7 @@ public async Task Return_UnaryResultOfRefType() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyService : IService @@ -96,7 +99,7 @@ public async Task Invalid_Return_TaskOfUnaryResultOfT() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyService : IService @@ -106,7 +109,12 @@ public interface IMyService : IService } """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source); + var verifierOptions = VerifierOptions.Default with + { + TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, + ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error)} + }; + await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); } [Fact] @@ -117,7 +125,7 @@ public async Task Return_StreamingResult() using MessagePack; using MagicOnion; using System.Threading.Tasks; - + namespace TempProject { public interface IMyService : IService @@ -140,7 +148,7 @@ public async Task Invalid_Return_NonGenerics() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyService : IService @@ -150,7 +158,12 @@ public interface IMyService : IService } """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source); + var verifierOptions = VerifierOptions.Default with + { + TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, + ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error)} + }; + await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); } [Fact] @@ -161,7 +174,7 @@ public async Task Invalid_Return_NonSupportedUnaryResultOfT() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyService : IService @@ -171,7 +184,12 @@ public interface IMyService : IService } """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source); + var verifierOptions = VerifierOptions.Default with + { + TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, + ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.UnaryUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error)} + }; + await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); } [Fact] @@ -182,7 +200,7 @@ public async Task Invalid_Return_RawStreaming_NonTask() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyService : IService @@ -194,6 +212,16 @@ public interface IMyService : IService } """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source); + var verifierOptions = VerifierOptions.Default with + { + TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, + ExpectedDiagnostics = new[] + { + new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error), + new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error), + new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error), + } + }; + await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs index de422b29d..e4eb020d6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs @@ -1,4 +1,7 @@ +using MagicOnion.Client.SourceGenerator.CodeAnalysis; using MagicOnion.Client.SourceGenerator.Tests.Verifiers; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Testing; namespace MagicOnion.Client.SourceGenerator.Tests; @@ -12,7 +15,7 @@ public async Task Complex() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver @@ -20,7 +23,7 @@ public interface IMyHubReceiver void OnMessage(); void OnMessage2(MyObject a); void OnMessage3(MyObject a, string b, int c); - + } public interface IMyHub : IStreamingHub { @@ -30,7 +33,7 @@ public interface IMyHub : IStreamingHub Task D(MyObject a, string b, int c); Task E(MyObject a, string b, int c); } - + [MessagePackObject] public class MyObject { @@ -49,7 +52,7 @@ public async Task HubReceiver_Parameter_Zero() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver @@ -60,7 +63,7 @@ public interface IMyHub : IStreamingHub { Task A(MyObject a); } - + [MessagePackObject] public class MyObject { @@ -79,7 +82,7 @@ public async Task HubReceiver_Parameter_One() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver @@ -90,7 +93,7 @@ public interface IMyHub : IStreamingHub { Task A(MyObject a); } - + [MessagePackObject] public class MyObject { @@ -109,7 +112,7 @@ public async Task HubReceiver_Parameter_Many() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver @@ -120,7 +123,7 @@ public interface IMyHub : IStreamingHub { Task A(MyObject a); } - + [MessagePackObject] public class MyObject { @@ -139,7 +142,7 @@ public async Task Return_Task() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver { } @@ -147,7 +150,7 @@ public interface IMyHub : IStreamingHub { Task A(MyObject a); } - + [MessagePackObject] public class MyObject { @@ -166,7 +169,7 @@ public async Task Return_TaskOfT() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver { } @@ -174,7 +177,7 @@ public interface IMyHub : IStreamingHub { Task A(MyObject a); } - + [MessagePackObject] public class MyObject { @@ -193,7 +196,7 @@ public async Task Return_ValueTask() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver { } @@ -201,7 +204,7 @@ public interface IMyHub : IStreamingHub { ValueTask A(MyObject a); } - + [MessagePackObject] public class MyObject { @@ -220,7 +223,7 @@ public async Task Return_ValueTaskOfT() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver { } @@ -228,7 +231,7 @@ public interface IMyHub : IStreamingHub { ValueTask A(MyObject a); } - + [MessagePackObject] public class MyObject { @@ -247,7 +250,7 @@ public async Task Invalid_Return_Void() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver { } @@ -258,7 +261,15 @@ public interface IMyHub : IStreamingHub } """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source); + var verifierOptions = VerifierOptions.Default with + { + TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, + ExpectedDiagnostics = new[] + { + new DiagnosticResult(MagicOnionDiagnosticDescriptors.StreamingHubUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error), + } + }; + await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); } [Fact] @@ -269,7 +280,7 @@ public async Task Invalid_HubReceiver_ReturnsNotVoid() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver @@ -282,7 +293,15 @@ public interface IMyHub : IStreamingHub } """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source); + var verifierOptions = VerifierOptions.Default with + { + TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, + ExpectedDiagnostics = new[] + { + new DiagnosticResult(MagicOnionDiagnosticDescriptors.StreamingHubUnsupportedReceiverMethodReturnType.Id, DiagnosticSeverity.Error), + } + }; + await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); } [Fact] @@ -293,7 +312,7 @@ public async Task Parameter_Zero() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver { } @@ -315,7 +334,7 @@ public async Task Parameter_One() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + namespace TempProject { public interface IMyHubReceiver { } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index 0677e4bd3..7f090ab2e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -17,9 +17,16 @@ namespace MagicOnion.Client.SourceGenerator.Tests.Verifiers; -internal record VerifierOptions(bool UseMemoryPack) +internal record VerifierOptions { - public static VerifierOptions Default { get; } = new VerifierOptions(UseMemoryPack: false); + public bool UseMemoryPack { get; init; } + public TestBehaviors? TestBehaviorsOverride { get; init; } + public IReadOnlyList? ExpectedDiagnostics { get; init; } + + public static VerifierOptions Default { get; } = new VerifierOptions + { + UseMemoryPack = false, + }; } internal class MagicOnionSourceGeneratorVerifier @@ -53,6 +60,16 @@ public static async Task RunAsync(IEnumerable<(string Path, string Content)> tes if (verifierOptions is not null) { + if (verifierOptions.ExpectedDiagnostics is not null) + { + test.ExpectedDiagnostics.AddRange(verifierOptions.ExpectedDiagnostics); + } + + if (verifierOptions.TestBehaviorsOverride is not null) + { + test.TestBehaviors = verifierOptions.TestBehaviorsOverride.Value; + } + if (verifierOptions.UseMemoryPack) { // MemoryPack.Core From 989750729deeef1ec083ab56c26c905f0447643d Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 17 Oct 2023 11:21:05 +0900 Subject: [PATCH 31/66] Share source codes for Roslyn 3 and 4 --- ...cOnion.Client.SourceGenerator.Unity.csproj | 4 +- ...agicOnionClientSourceGenerator.Roslyn3.cs} | 38 +++++++++++-------- .../MagicOnionDiagnosticDescriptors.cs | 4 +- .../MagicOnionClientSourceGenerator.Emit.cs | 25 ++++++++++++ .../MagicOnionClientSourceGenerator.cs | 15 +------- 5 files changed, 55 insertions(+), 31 deletions(-) rename src/MagicOnion.Client.SourceGenerator.Unity/{MagicOnionClientSourceGeneratorRoslyn3.cs => MagicOnionClientSourceGenerator.Roslyn3.cs} (53%) create mode 100644 src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj index 3823e462e..5507cdce6 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -11,6 +11,7 @@ true cs + MagicOnion.Client.SourceGenerator @@ -21,6 +22,7 @@ + @@ -28,7 +30,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive
- + diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGeneratorRoslyn3.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs similarity index 53% rename from src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGeneratorRoslyn3.cs rename to src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs index 929fb5629..e0fcb72ae 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGeneratorRoslyn3.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs @@ -3,10 +3,10 @@ using MagicOnion.Client.SourceGenerator.Internal; using Microsoft.CodeAnalysis; -namespace MagicOnion.Client.SourceGenerator.Unity; +namespace MagicOnion.Client.SourceGenerator; [Generator] -public class MagicOnionClientSourceGeneratorRoslyn3 : ISourceGenerator +public partial class MagicOnionClientSourceGenerator : ISourceGenerator { public void Initialize(GeneratorInitializationContext context) { @@ -19,20 +19,7 @@ public void Execute(GeneratorExecutionContext context) var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); if (ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) { - var interfaceSymbols = syntaxReceiver.Candidates - .Select(x => (INamedTypeSymbol)context.Compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!) - .ToImmutableArray(); - var (serviceCollection, diagnostics) = MethodCollector.Collect(interfaceSymbols, referenceSymbols, context.CancellationToken); - var generated = MagicOnionClientGenerator.Generate(serviceCollection, options, context.CancellationToken); - - foreach (var diagnostic in diagnostics) - { - context.ReportDiagnostic(diagnostic); - } - foreach (var (path, source) in generated) - { - context.AddSource(path, source); - } + Generate(syntaxReceiver.Candidates.ToImmutableArray(), context.Compilation, referenceSymbols, new SourceProductionContext(context), options); } } } @@ -49,3 +36,22 @@ public void OnVisitSyntaxNode(SyntaxNode syntaxNode) } } } + +readonly struct SourceProductionContext +{ + readonly GeneratorExecutionContext context; + + public SourceProductionContext(GeneratorExecutionContext context) + { + this.context = context; + } + + public CancellationToken CancellationToken + => context.CancellationToken; + + public void AddSource(string hintName, string source) + => context.AddSource(hintName, source); + + public void ReportDiagnostic(Diagnostic diagnostic) + => context.ReportDiagnostic(diagnostic); +} diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs index 74f67988f..87866f9d4 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs @@ -2,6 +2,8 @@ namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; +#pragma warning disable RS2008 // Enable analyzer release tracking for the analyzer project containing rule '{0}' + public static class MagicOnionDiagnosticDescriptors { public static readonly DiagnosticDescriptor StreamingHubUnsupportedReceiverMethodReturnType = @@ -28,7 +30,7 @@ public static class MagicOnionDiagnosticDescriptors new DiagnosticDescriptor( id: "MOC1003", title: "Must be UnaryResult or Task of StreamingResult", - messageFormat: "Unsupported return type '{0}' ({1}). Allowed return types are UnaryResult and Task of StreamingResult", + messageFormat: "Unsupported return type '{0}' ({1}). Allowed return types are UnaryResult and Task of StreamingResult.", category: "Usage", description: "The service method has unsupported return type.", defaultSeverity: DiagnosticSeverity.Error, diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs new file mode 100644 index 000000000..389e9de0c --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs @@ -0,0 +1,25 @@ +using System.Collections.Immutable; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; +using Microsoft.CodeAnalysis; + +namespace MagicOnion.Client.SourceGenerator; + +public partial class MagicOnionClientSourceGenerator +{ + static void Generate(ImmutableArray interfaces, Compilation compilation, ReferenceSymbols referenceSymbols, SourceProductionContext sourceProductionContext, GeneratorOptions options) + { + var interfaceSymbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); + var (serviceCollection, diagnostics) = MethodCollector.Collect(interfaceSymbols, referenceSymbols, sourceProductionContext.CancellationToken); + var generated = MagicOnionClientGenerator.Generate(serviceCollection, options, sourceProductionContext.CancellationToken); + + foreach (var diagnostic in diagnostics) + { + sourceProductionContext.ReportDiagnostic(diagnostic); + } + + foreach (var (path, source) in generated) + { + sourceProductionContext.AddSource(path, source); + } + } +} diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 806ddaa68..370535a65 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -6,7 +6,7 @@ namespace MagicOnion.Client.SourceGenerator; [Generator(LanguageNames.CSharp)] -public class MagicOnionClientSourceGenerator : IIncrementalGenerator +public partial class MagicOnionClientSourceGenerator : IIncrementalGenerator { public void Initialize(IncrementalGeneratorInitializationContext context) { @@ -33,18 +33,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) var (((options, interfaces), referenceSymbols), compilation) = values; if (referenceSymbols is null) return; - var interfaceSymbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); - var (serviceCollection, diagnostics) = MethodCollector.Collect(interfaceSymbols, referenceSymbols, sourceProductionContext.CancellationToken); - var generated = MagicOnionClientGenerator.Generate(serviceCollection, options, sourceProductionContext.CancellationToken); - - foreach (var diagnostic in diagnostics) - { - sourceProductionContext.ReportDiagnostic(diagnostic); - } - foreach (var (path, source) in generated) - { - sourceProductionContext.AddSource(path, source); - } + Generate(interfaces, compilation, referenceSymbols, sourceProductionContext, options); }); } } From 541d636a524a2265cd0c26e0e05e03d78673ff82 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 12:40:14 +0900 Subject: [PATCH 32/66] WIP: Introduce MagicOnionClientGeneration attribute --- MagicOnion.sln | 9 +- ...MagicOnionClientSourceGenerator.Roslyn3.cs | 8 +- .../CodeGen/MagicOnionInitializerGenerator.cs | 119 ++++++++++-------- ...emoryPackFormatterRegistrationGenerator.cs | 1 + .../MessagePackEnumFormatterGenerator.cs | 1 + .../MessagePackFormatterResolverGenerator.cs | 1 + .../StaticMagicOnionClientGenerator.cs | 1 + .../StaticStreamingHubClientGenerator.cs | 1 + .../MagicOnionClientGenerator.cs | 8 +- .../MagicOnionClientSourceGenerator.Emit.cs | 50 +++++++- .../MagicOnionClientSourceGenerator.cs | 76 ++++++++--- .../Utils/RoslynExtensions.cs | 9 ++ .../CompilationHelper.cs | 20 +-- .../GenerateEnumFormatterTest.cs | 20 +++ .../GenerateGenericsStreamingHubTest.cs | 118 ++++++++++++++++- .../GenerateGenericsTest.cs | 76 +++++++++++ .../GenerateRawStreamingTest.cs | 4 + .../GenerateServiceTest.cs | 46 ++++++- .../GenerateStreamingHubTest.cs | 78 ++++++++++-- .../GenerateTest.cs | 56 ++++++++- .../GenerateWithIfDirectiveTest.cs | 8 ++ ...cOnion.Client.SourceGenerator.Tests.csproj | 4 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...on_Formatters_MyClass_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../HubReceiver/TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../Parameters/TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../Return/TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../Return_Enum/TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../Return/TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 8 +- .../TempProject_MagicOnionInitializer.g.cs | 82 ++++++++++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...icOnion_Resolvers_MagicOnionResolver.g.cs} | 14 +-- .../TempProject_MagicOnionInitializer.g.cs | 82 ++++++++++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 11 +- .../TempProject_MagicOnionInitializer.g.cs | 82 ++++++++++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 68 ++++++++++ .../TempProject_MagicOnionInitializer.g.cs | 82 ++++++++++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../Complex/TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 68 ++++++++++ .../TempProject_MagicOnionInitializer.g.cs | 82 ++++++++++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 68 ++++++++++ .../TempProject_MagicOnionInitializer.g.cs | 82 ++++++++++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../Return_Task/TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../MyApplication1_GreeterServiceClient.g.cs | 1 + .../MyApplication1_MagicOnionInitializer.g.cs | 86 +++++++++++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...on_Formatters_ApartmentStateFormatter.g.cs | 1 + ...ters_ClientCertificateOptionFormatter.g.cs | 1 + ...gicOnion_Formatters_FileModeFormatter.g.cs | 1 + ...rmatters_TaskCreationOptionsFormatter.g.cs | 1 + .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../MyNamespace_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../MyNamespace_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 3 + .../MyApplication1_GreeterServiceClient.g.cs | 9 ++ .../MyApplication1_MagicOnionInitializer.g.cs | 86 +++++++++++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyServiceClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 1 + .../TempProject_MagicOnionInitializer.g.cs | 86 +++++++++++++ .../TempProject_MyHubClient.g.cs | 1 + ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ .../MyApplication1_GreeterServiceClient.g.cs | 45 ------- ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 76 ----------- .../MyApplication1_GreeterServiceClient.g.cs | 45 ------- ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ .../MyApplication1_GreeterServiceClient.g.cs | 45 ------- ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MyApplication1_GreeterServiceClient.g.cs | 45 ------- .../__Generated___MagicOnionInitializer.g.cs | 81 ------------ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++++ .../MagicOnion_MagicOnionInitializer.g.cs | 81 ------------ ...MagicOnionMemoryPackFormatterProvider.g.cs | 16 --- .../RunTest.cs | 58 ++++++++- .../MagicOnionSourceGeneratorVerifier.cs | 2 +- .../MagicOnionGeneratedClientInitializer.cs | 7 ++ .../SampleServiceDefinitions.csproj | 13 ++ .../Services/IGreeterService.cs | 10 ++ 452 files changed, 10020 insertions(+), 6731 deletions(-) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnionClientSourceGeneratorAttributes.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GeneratorOptionsTest/DisableAutoRegister => GenerateServiceTest/Invalid_Return_NonGenerics}/MagicOnion_Resolvers_MagicOnionResolver.g.cs (75%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs => GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs} (71%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnionClientSourceGeneratorAttributes.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GeneratorOptionsTest/MessagePackFormatterNamespace => GenerateServiceTest/Invalid_Return_RawStreaming_NonTask}/MagicOnion_Resolvers_MagicOnionResolver.g.cs (66%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnionClientSourceGeneratorAttributes.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnionClientSourceGeneratorAttributes.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnion_Resolvers_MagicOnionResolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/MagicOnionClientSourceGeneratorAttributes.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnionClientSourceGeneratorAttributes.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GeneratorOptionsTest/Default => GenerateTest/NotPartial}/MagicOnion_Resolvers_MagicOnionResolver.g.cs (92%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GeneratorOptionsTest/Serializer_MemoryPack => GenerateTest/NotPartial}/MyApplication1_GreeterServiceClient.g.cs (64%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnionClientSourceGeneratorAttributes.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs create mode 100644 tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs create mode 100644 tests/samples/SampleServiceDefinitions/SampleServiceDefinitions.csproj create mode 100644 tests/samples/SampleServiceDefinitions/Services/IGreeterService.cs diff --git a/MagicOnion.sln b/MagicOnion.sln index 77c323f9e..cf57a0cd7 100644 --- a/MagicOnion.sln +++ b/MagicOnion.sln @@ -102,7 +102,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGenerator.Tests", "tests\MagicOnion.Client.SourceGenerator.Tests\MagicOnion.Client.SourceGenerator.Tests.csproj", "{632C8D1B-3293-4D02-9ED1-0CB191619334}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicOnion.Client.SourceGenerator.Unity", "src\MagicOnion.Client.SourceGenerator.Unity\MagicOnion.Client.SourceGenerator.Unity.csproj", "{A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGenerator.Unity", "src\MagicOnion.Client.SourceGenerator.Unity\MagicOnion.Client.SourceGenerator.Unity.csproj", "{A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleServiceDefinitions", "tests\samples\SampleServiceDefinitions\SampleServiceDefinitions.csproj", "{45EA8028-41C1-4DF6-9E0F-EEE8967799DA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -230,6 +232,10 @@ Global {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}.Release|Any CPU.Build.0 = Release|Any CPU + {45EA8028-41C1-4DF6-9E0F-EEE8967799DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45EA8028-41C1-4DF6-9E0F-EEE8967799DA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45EA8028-41C1-4DF6-9E0F-EEE8967799DA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45EA8028-41C1-4DF6-9E0F-EEE8967799DA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -270,6 +276,7 @@ Global {7130EC5B-C987-487A-B319-E91B6D03F5BF} = {1987061F-8970-4018-8D58-6932961C9EB4} {632C8D1B-3293-4D02-9ED1-0CB191619334} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD} = {1987061F-8970-4018-8D58-6932961C9EB4} + {45EA8028-41C1-4DF6-9E0F-EEE8967799DA} = {B5617CC1-55FD-4F77-BA75-9450474C6527} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D5B2E7E3-B727-40A1-BE68-7BAC9B9DE2FE} diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs index e0fcb72ae..29d238d6c 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs @@ -10,7 +10,8 @@ public partial class MagicOnionClientSourceGenerator : ISourceGenerator { public void Initialize(GeneratorInitializationContext context) { - context.RegisterForSyntaxNotifications(() => new SyntaxContextReceiver()); + context.RegisterForSyntaxNotifications(static () => new SyntaxContextReceiver()); + context.RegisterForPostInitialization(static context => AddAttributeSources(context.AddSource)); } public void Execute(GeneratorExecutionContext context) @@ -19,7 +20,8 @@ public void Execute(GeneratorExecutionContext context) var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); if (ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) { - Generate(syntaxReceiver.Candidates.ToImmutableArray(), context.Compilation, referenceSymbols, new SourceProductionContext(context), options); + var generationContext = new GenerationContext(null, "MagicOnionInitializer", new SourceProductionContext(context)); + Generate(generationContext, syntaxReceiver.Candidates.ToImmutableArray(), context.Compilation, referenceSymbols); } } } @@ -37,7 +39,7 @@ public void OnVisitSyntaxNode(SyntaxNode syntaxNode) } } -readonly struct SourceProductionContext +public readonly struct SourceProductionContext { readonly GeneratorExecutionContext context; diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs index e8f79e159..1c90aef4d 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs @@ -5,120 +5,137 @@ namespace MagicOnion.Client.SourceGenerator.CodeGen; internal class MagicOnionInitializerGenerator { - public static string Build(GeneratorOptions options, MagicOnionServiceCollection serviceCollection) + public static string Build(string? @namespace, string typeName, GeneratorOptions options, MagicOnionServiceCollection serviceCollection) { var writer = new StringWriter(); writer.WriteLine($$""" // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete - - namespace {{options.Namespace}} + #pragma warning disable CS8019 // Unnecessary using directive. + """); + if (!string.IsNullOrEmpty(@namespace)) + { + writer.WriteLine($$""" + namespace {{@namespace}} { + """); + } + writer.WriteLine($$""" using global::System; using global::System.Collections.Generic; using global::System.Linq; using global::MagicOnion; using global::MagicOnion.Client; - public static partial class MagicOnionInitializer + partial class {{typeName}} { - static bool isRegistered = false; - + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static {{typeName}} Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; """); if (!options.DisableAutoRegister) { writer.WriteLine($$""" #if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] + [global::System.Runtime.CompilerServices.ModuleInitializer] #endif + static void Register() => Instance.TryRegisterProviderFactory(); """); } writer.WriteLine($$""" - public static void Register() + + public bool TryRegisterProviderFactory() { - if (isRegistered) return; + if (isRegistered) return false; isRegistered = true; global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; + return true; + } - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; - static MagicOnionClientFactoryCache() + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); """); foreach (var serviceInfo in serviceCollection.Services) { writer.WriteLine($$""" - if (typeof(T) == typeof({{serviceInfo.ServiceType.FullName}})) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate<{{serviceInfo.ServiceType.FullName}}>)((x, y) => new {{serviceInfo.GetClientFullName()}}(x, y))); - } + if (typeof(T) == typeof({{serviceInfo.ServiceType.FullName}})) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate<{{serviceInfo.ServiceType.FullName}}>)((x, y) => new {{serviceInfo.GetClientFullName()}}(x, y))); + } """); } writer.WriteLine($$""" - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); """); foreach (var hubInfo in serviceCollection.Hubs) { writer.WriteLine($$""" - if (typeof(TStreamingHub) == typeof({{hubInfo.ServiceType.FullName}}) && typeof(TReceiver) == typeof({{hubInfo.Receiver.ReceiverType.FullName}})) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate<{{hubInfo.ServiceType.FullName}}, {{hubInfo.Receiver.ReceiverType.FullName}}>)((a, _, b, c, d, e) => new {{hubInfo.GetClientFullName()}}(a, b, c, d, e))); - } + if (typeof(TStreamingHub) == typeof({{hubInfo.ServiceType.FullName}}) && typeof(TReceiver) == typeof({{hubInfo.Receiver.ReceiverType.FullName}})) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate<{{hubInfo.ServiceType.FullName}}, {{hubInfo.Receiver.ReceiverType.FullName}}>)((a, _, b, c, d, e) => new {{hubInfo.GetClientFullName()}}(a, b, c, d, e))); + } """); } - writer.WriteLine($$""" + writer.WriteLine($$$""" - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } } } } - + """); + if (!string.IsNullOrEmpty(@namespace)) + { + writer.WriteLine($$""" } """); + } return writer.ToString(); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs index 709476d0c..22dafd848 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs @@ -19,6 +19,7 @@ static void EmitPreamble(SerializationFormatterCodeGenContext ctx) // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete + #pragma warning disable CS8019 // Unnecessary using directive. """); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs index c3ee882f0..0227f6408 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs @@ -11,6 +11,7 @@ public static string Build(string @namespace, IEnumerable // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete + #pragma warning disable CS8019 // Unnecessary using directive. """); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs index d17d5352f..9b51824cd 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs @@ -19,6 +19,7 @@ static void EmitPreamble(SerializationFormatterCodeGenContext ctx) // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete + #pragma warning disable CS8019 // Unnecessary using directive. """); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs index 5030bacdf..d87ef542e 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs @@ -45,6 +45,7 @@ static void EmitHeader(IndentedTextWriter textWriter) // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete + #pragma warning disable CS8019 // Unnecessary using directive. """); textWriter.WriteLine(); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs index ef0f074a6..26b463407 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs @@ -46,6 +46,7 @@ static void EmitHeader(IndentedTextWriter textWriter) #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used + #pragma warning disable CS8019 // Unnecessary using directive. """); textWriter.WriteLine(); } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs index 8338e2fa0..d84222542 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs @@ -1,17 +1,17 @@ -using System.Collections.Immutable; using MagicOnion.Client.SourceGenerator.CodeAnalysis; using MagicOnion.Client.SourceGenerator.CodeGen; using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; -using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator; public static class MagicOnionClientGenerator { - public static IReadOnlyList<(string Path, string Source)> Generate(MagicOnionServiceCollection serviceCollection, GeneratorOptions options, CancellationToken cancellationToken) + public static IReadOnlyList<(string Path, string Source)> Generate(GenerationContext context, MagicOnionServiceCollection serviceCollection, CancellationToken cancellationToken) { var outputs = new List<(string Path, string Source)>(); + var options = GeneratorOptions.Default; + // . var namespaceDot = string.IsNullOrWhiteSpace(options.Namespace) ? string.Empty : options.Namespace + "."; // .Formatters @@ -50,7 +50,7 @@ public static class MagicOnionClientGenerator cancellationToken.ThrowIfCancellationRequested(); - outputs.Add((GeneratePathFromNamespaceAndTypeName(options.Namespace, "MagicOnionInitializer"), MagicOnionInitializerGenerator.Build(options, serviceCollection))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName), MagicOnionInitializerGenerator.Build(context.Namespace, context.InitializerPartialTypeName, options, serviceCollection))); outputs.Add((GeneratePathFromNamespaceAndTypeName(formatterCodeGenContext.Namespace, formatterCodeGenContext.InitializerName), resolverTexts)); foreach (var enumSerializationInfo in serializationInfoCollection.Enums) diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs index 389e9de0c..64a788260 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs @@ -4,22 +4,62 @@ namespace MagicOnion.Client.SourceGenerator; +public readonly record struct GenerationContext(string? Namespace, string InitializerPartialTypeName, SourceProductionContext SourceProductionContext); + public partial class MagicOnionClientSourceGenerator { - static void Generate(ImmutableArray interfaces, Compilation compilation, ReferenceSymbols referenceSymbols, SourceProductionContext sourceProductionContext, GeneratorOptions options) + public const string SourceGeneratorAttributesHintName = "MagicOnionClientSourceGeneratorAttributes.g.cs"; + public const string MagicOnionClientGenerationAttributeName = "MagicOnionClientGenerationAttribute"; + public const string MagicOnionClientGenerationAttributeFullName = $"MagicOnion.Client.{MagicOnionClientGenerationAttributeName}"; + + static void AddAttributeSources(Action addSource) + { + addSource(SourceGeneratorAttributesHintName, $$""" + // + namespace MagicOnion.Client + { + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class {{MagicOnionClientGenerationAttributeName}} : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public {{MagicOnionClientGenerationAttributeName}}(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } + } + """); + } + + static void Generate(GenerationContext context, ImmutableArray interfaces, Compilation compilation, ReferenceSymbols referenceSymbols) { var interfaceSymbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); - var (serviceCollection, diagnostics) = MethodCollector.Collect(interfaceSymbols, referenceSymbols, sourceProductionContext.CancellationToken); - var generated = MagicOnionClientGenerator.Generate(serviceCollection, options, sourceProductionContext.CancellationToken); + Generate(context, interfaceSymbols, referenceSymbols); + } + + static void Generate(GenerationContext context, ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) + { + var (serviceCollection, diagnostics) = MethodCollector.Collect(interfaceSymbols, referenceSymbols, context.SourceProductionContext.CancellationToken); + var generated = MagicOnionClientGenerator.Generate(context, serviceCollection, context.SourceProductionContext.CancellationToken); foreach (var diagnostic in diagnostics) { - sourceProductionContext.ReportDiagnostic(diagnostic); + context.SourceProductionContext.ReportDiagnostic(diagnostic); } foreach (var (path, source) in generated) { - sourceProductionContext.AddSource(path, source); + context.SourceProductionContext.AddSource(path, source); } } } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 370535a65..6bd1a08fb 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -1,7 +1,7 @@ using System.Collections.Immutable; using MagicOnion.Client.SourceGenerator.CodeAnalysis; -using MagicOnion.Client.SourceGenerator.Internal; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; namespace MagicOnion.Client.SourceGenerator; @@ -10,30 +10,66 @@ public partial class MagicOnionClientSourceGenerator : IIncrementalGenerator { public void Initialize(IncrementalGeneratorInitializationContext context) { - var options = context.AdditionalTextsProvider.Collect() - .Select(static (x, cancellationToken) => GeneratorOptions.Create(x, cancellationToken)) - .WithTrackingName("mo_GeneratorOptions"); var referenceSymbols = context.CompilationProvider .Select(static (x, cancellationToken) => ReferenceSymbols.TryCreate(x, out var rs) ? rs : default) .WithTrackingName("mo_ReferenceSymbols"); - var interfaces = context.SyntaxProvider.CreateSyntaxProvider( - predicate: static (node, ct) => SyntaxHelper.IsCandidateInterface(node), - transform: static (ctx, ct) => ctx.Node) - .Collect() - .WithTrackingName("mo_Interfaces"); - - var source = options - .Combine(interfaces) - .Combine(referenceSymbols) - .Combine(context.CompilationProvider) - .WithTrackingName("mo_Source"); - - context.RegisterSourceOutput(source, static (sourceProductionContext, values) => + var generationAttr = context.SyntaxProvider.ForAttributeWithMetadataName( + MagicOnionClientGenerationAttributeFullName, + predicate: static (node, cancellationToken) => true, + transform: static (ctx, cancellationToken) => ((ClassDeclarationSyntax)ctx.TargetNode, ctx.Attributes, ctx.SemanticModel)); + + context.RegisterPostInitializationOutput(static context => AddAttributeSources(context.AddSource)); + + context.RegisterSourceOutput(generationAttr.Combine(referenceSymbols), static (sourceProductionContext, value) => { - var (((options, interfaces), referenceSymbols), compilation) = values; - if (referenceSymbols is null) return; + var ((initializerClassDecl, attrs, semanticModel), referenceSymbols) = value; + if (referenceSymbols is null) return; // TODO: ReportDiagnostic + + var interfaceSymbols = new List(); + foreach (var attr in attrs) + { + // If the constructor has errors in the arguments, the first argument may be `Type` instead of `Array`. We need `Array` to proceed. + if (attr.ConstructorArguments[0].Kind != TypedConstantKind.Array) continue; + + foreach (var typeContainedInTargetAssembly in attr.ConstructorArguments[0].Values) // Type[] typesContainedInTargetAssembly + { + if (typeContainedInTargetAssembly.Value is INamedTypeSymbol typeSymbolContainedInTargetAssembly) + { + var scanTargetAssembly = typeSymbolContainedInTargetAssembly.ContainingAssembly; + if (scanTargetAssembly is null) continue; + + Traverse(scanTargetAssembly.GlobalNamespace, interfaceSymbols); + } + } + } + + var initializerClassSymbol = semanticModel.GetDeclaredSymbol(initializerClassDecl) as INamedTypeSymbol; + if (initializerClassSymbol is null) return; // TODO: ReportDiagnostic + + // TODO: ReportDiagnostic if the class is not partial. + + var initializerPartialTypeNamespace = initializerClassSymbol.ContainingNamespace.IsGlobalNamespace + ? null + : initializerClassSymbol.ContainingNamespace.Name; + var initializerPartialTypeName = initializerClassSymbol.Name; + + var generationContext = new GenerationContext(initializerPartialTypeNamespace, initializerPartialTypeName, sourceProductionContext); + Generate(generationContext, interfaceSymbols.ToImmutableArray(), referenceSymbols); - Generate(interfaces, compilation, referenceSymbols, sourceProductionContext, options); + static void Traverse(INamespaceOrTypeSymbol rootNamespaceOrTypeSymbol, List interfaceSymbols) + { + foreach (var namespaceOrTypeSymbol in rootNamespaceOrTypeSymbol.GetMembers()) + { + if (namespaceOrTypeSymbol is INamedTypeSymbol { TypeKind: TypeKind.Interface } typeSymbol) + { + interfaceSymbols.Add(typeSymbol); + } + else if (namespaceOrTypeSymbol is INamespaceSymbol namespaceSymbol) + { + Traverse(namespaceSymbol, interfaceSymbols); + } + } + } }); } } diff --git a/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs index e780ed2e6..bcfeedc1c 100644 --- a/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs @@ -25,4 +25,13 @@ public static bool ApproximatelyEqual(this ITypeSymbol left, ITypeSymbol right) return SymbolEqualityComparer.Default.Equals(left, right); } } + + public static Location? GetLocation(this ISymbol typeSymbol) + => typeSymbol.Locations.Length > 0 ? typeSymbol.Locations[0] : null; + + public static Location? GetLocation(this AttributeData attributeData) + { + SyntaxReference? reference = attributeData.ApplicationSyntaxReference; + return reference?.SyntaxTree.GetLocation(reference.Span); + } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs index acfce9dfd..18792b40f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/CompilationHelper.cs @@ -1,5 +1,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +using SampleServiceDefinitions.Services; namespace MagicOnion.Client.SourceGenerator.Tests; @@ -21,17 +22,22 @@ public static (Compilation Compilation, SemanticModel SemanticModel) Create(stri MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Memory.dll")), MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "netstandard.dll")), MetadataReference.CreateFromFile(typeof(object).Assembly.Location), - MetadataReference.CreateFromFile(typeof(MagicOnion.IService<>).Assembly.Location), // Abstractions - MetadataReference.CreateFromFile(typeof(MagicOnion.Client.MagicOnionClient).Assembly.Location), // Client - MetadataReference.CreateFromFile(typeof(MagicOnion.GrpcMethodHelper).Assembly.Location), // Shared + MetadataReference.CreateFromFile(typeof(Grpc.Core.AsyncUnaryCall<>).Assembly.Location), // Grpc.Core.Api + MetadataReference.CreateFromFile(typeof(Grpc.Net.Client.GrpcChannel).Assembly.Location), // Grpc.Net.Client + MetadataReference.CreateFromFile(typeof(MessagePack.MessagePackSerializer).Assembly.Location), // MessagePack + MetadataReference.CreateFromFile(typeof(MessagePack.MessagePackObjectAttribute).Assembly.Location), // MessagePack.Annotations + MetadataReference.CreateFromFile(typeof(MagicOnion.IService<>).Assembly.Location), // MagicOnion.Abstractions + MetadataReference.CreateFromFile(typeof(MagicOnion.Client.MagicOnionClient).Assembly.Location), // MagicOnion.Client + MetadataReference.CreateFromFile(typeof(MagicOnion.GrpcMethodHelper).Assembly.Location), // MagicOnion.Shared + MetadataReference.CreateFromFile(typeof(IGreeterService).Assembly.Location), // SampleServiceDefinitions }; var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); var compilation = CSharpCompilation.Create(assemblyName, new [] { syntaxTree }, references, compilationOptions); - if (compilation.GetDiagnostics().Any(x => x.Severity == DiagnosticSeverity.Error)) - { - throw new InvalidOperationException("Failed to compile the source code. \n" + string.Join(Environment.NewLine, compilation.GetDiagnostics().Select(x => x.ToString()))); - } + //if (compilation.GetDiagnostics().Any(x => x.Severity == DiagnosticSeverity.Error)) + //{ + // throw new InvalidOperationException("Failed to compile the source code. \n" + string.Join(Environment.NewLine, compilation.GetDiagnostics().Select(x => x.ToString()))); + //} return (compilation, compilation.GetSemanticModel(syntaxTree)); } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateEnumFormatterTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateEnumFormatterTest.cs index fa67f8b7d..74832d0cf 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateEnumFormatterTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateEnumFormatterTest.cs @@ -11,6 +11,7 @@ public async Task GenerateEnumFormatter_Return() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -23,6 +24,9 @@ public enum MyEnum { A, B, C } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -36,6 +40,7 @@ public async Task GenerateEnumFormatter_Return_Nullable() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -48,6 +53,9 @@ public enum MyEnum { A, B, C } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -61,6 +69,7 @@ public async Task GenerateEnumFormatter_Parameter() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -73,6 +82,9 @@ public enum MyEnum { A, B, C } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -86,6 +98,7 @@ public async Task GenerateEnumFormatter_Parameter_Nullable() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -98,6 +111,9 @@ public enum MyEnum { A, B, C } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -111,6 +127,7 @@ public async Task GenerateEnumFormatter_Nested() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -126,6 +143,9 @@ public enum MyEnum A, B, C } } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs index a22381329..ffd5472dd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsStreamingHubTest.cs @@ -12,6 +12,7 @@ public async Task Parameters() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -31,6 +32,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -55,6 +59,7 @@ public async Task Parameters_MultipleTypeArgs() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -74,6 +79,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -98,6 +106,7 @@ public async Task Parameters_Nested() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -118,6 +127,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -142,6 +154,7 @@ public async Task Parameters_Nested_Enum() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -160,6 +173,9 @@ public enum MyEnum public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -184,6 +200,7 @@ public async Task Parameters_Nested_Array() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -200,6 +217,9 @@ public class MyGenericObject public class MyNestedGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -225,6 +245,7 @@ public async Task Parameters_ListFormatter_KnownType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -234,6 +255,9 @@ public interface IMyHub : IStreamingHub Task GetStringValuesAsync(List arg0); Task GetIntValuesAsync(List arg0); } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -249,6 +273,7 @@ public async Task Parameters_ListFormatter_UserType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -260,6 +285,9 @@ public interface IMyHub : IStreamingHub public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -274,6 +302,7 @@ public async Task Parameters_ArrayFormatter_KnownType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -286,6 +315,9 @@ public interface IMyHub : IStreamingHub Task GetSingleValuesAsync(float[] arg0); Task GetBooleanValuesAsync(bool[] arg0); } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -300,6 +332,7 @@ public async Task Parameters_ArrayFormatter_UserType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -312,6 +345,9 @@ public interface IMyHub : IStreamingHub public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -326,6 +362,7 @@ public async Task Return() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -345,6 +382,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -355,7 +395,7 @@ public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessa public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyGenericObject value, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); public global::TempProject.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } - } + } """; await MagicOnionSourceGeneratorVerifier.RunAsync(source); @@ -369,6 +409,7 @@ public async Task Return_Nested() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -389,6 +430,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -413,6 +457,7 @@ public async Task Return_MultipleTypeArgs() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -432,6 +477,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -456,6 +504,7 @@ public async Task Return_Enum() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -474,6 +523,9 @@ public enum MyEnum public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -498,6 +550,7 @@ public async Task Return_Nested_Enum() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -516,6 +569,9 @@ public enum MyEnum public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -540,6 +596,7 @@ public async Task Return_Nested_Array() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -556,6 +613,9 @@ public class MyGenericObject public class MyNestedGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -581,6 +641,7 @@ public async Task Return_ListFormatter_KnownType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -590,6 +651,9 @@ public interface IMyHub : IStreamingHub Task> GetStringValuesAsync(); Task> GetIntValuesAsync(); } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -605,6 +669,7 @@ public async Task Return_ListFormatter_UserType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -616,6 +681,9 @@ public interface IMyHub : IStreamingHub public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -630,6 +698,7 @@ public async Task Return_ArrayFormatter_KnownType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -642,6 +711,9 @@ public interface IMyHub : IStreamingHub Task GetSingleValuesAsync(); Task GetBooleanValuesAsync(); } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -656,6 +728,7 @@ public async Task Return_ArrayFormatter_UserType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -668,6 +741,9 @@ public interface IMyHub : IStreamingHub public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -682,6 +758,7 @@ public async Task HubReceiver() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -703,6 +780,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -727,6 +807,7 @@ public async Task HubReceiver_Nested() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -749,6 +830,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -773,6 +857,7 @@ public async Task HubReceiver_MultipleTypeArgs() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -794,6 +879,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -818,6 +906,7 @@ public async Task HubReceiver_Enum() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -838,6 +927,9 @@ public enum MyEnum public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -862,6 +954,7 @@ public async Task HubReceiver_Nested_Enum() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -882,6 +975,9 @@ public enum MyEnum public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -906,6 +1002,7 @@ public async Task HubReceiver_Nested_Array() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -924,6 +1021,9 @@ public class MyGenericObject public class MyNestedGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -949,6 +1049,7 @@ public async Task HubReceiver_ListFormatter_KnownType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -960,6 +1061,9 @@ public interface IMyHubReceiver public interface IMyHub : IStreamingHub { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -975,6 +1079,7 @@ public async Task HubReceiver_ListFormatter_UserType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -988,6 +1093,9 @@ public interface IMyHub : IStreamingHub public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -1002,6 +1110,7 @@ public async Task HubReceiver_ArrayFormatter_KnownType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -1016,6 +1125,9 @@ public interface IMyHubReceiver public interface IMyHub : IStreamingHub { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -1030,6 +1142,7 @@ public async Task HubReceiver_ArrayFormatter_UserType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -1044,6 +1157,9 @@ public interface IMyHub : IStreamingHub public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs index 88fd7a158..16d3f5259 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateGenericsTest.cs @@ -11,6 +11,7 @@ public async Task Parameters() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; using System.Collections.Generic; namespace TempProject @@ -31,6 +32,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -54,6 +58,7 @@ public async Task Parameters_Nested() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -73,6 +78,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -96,6 +104,7 @@ public async Task Parameters_Nested_Enum() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -113,6 +122,9 @@ public enum MyEnum public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -137,6 +149,7 @@ public async Task Parameters_Nested_Array() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -152,6 +165,9 @@ public class MyGenericObject public class MyNestedGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -177,6 +193,7 @@ public async Task Parameters_ListFormatter_KnownType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -185,6 +202,9 @@ public interface IMyService : IService UnaryResult GetStringValuesAsync(List arg0); UnaryResult GetIntValuesAsync(List arg0); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -200,6 +220,7 @@ public async Task Parameters_ListFormatter_UserType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -210,6 +231,9 @@ public interface IMyService : IService public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -224,6 +248,7 @@ public async Task Parameters_ArrayFormatter_KnownType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -235,6 +260,9 @@ public interface IMyService : IService UnaryResult GetSingleValuesAsync(float[] arg0); UnaryResult GetBooleanValuesAsync(bool[] arg0); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -249,6 +277,7 @@ public async Task Parameters_ArrayFormatter_UserType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -260,6 +289,9 @@ public interface IMyService : IService public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -273,6 +305,7 @@ public async Task Return() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -291,6 +324,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -314,6 +350,7 @@ public async Task Return_Nested() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -333,6 +370,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -356,6 +396,7 @@ public async Task Return_MultipleTypeArgs() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -374,6 +415,9 @@ public class MyObject public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -397,6 +441,7 @@ public async Task Return_Enum() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -414,6 +459,9 @@ public enum MyEnum public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -437,6 +485,7 @@ public async Task Return_Nested_Enum() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -454,6 +503,9 @@ public enum MyEnum public class MyGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -478,6 +530,7 @@ public async Task Return_Nested_Array() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -493,6 +546,9 @@ public class MyGenericObject public class MyNestedGenericObject { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } // Pseudo generated MessagePackFormatter using mpc (MessagePack.Generator) @@ -518,6 +574,7 @@ public async Task Return_ListFormatter_KnownType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -526,6 +583,9 @@ public interface IMyService : IService UnaryResult> GetStringValuesAsync(); UnaryResult> GetIntValuesAsync(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -541,6 +601,7 @@ public async Task Return_ListFormatter_UserType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -551,6 +612,9 @@ public interface IMyService : IService public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -565,6 +629,7 @@ public async Task Return_ArrayFormatter_KnownType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -576,6 +641,9 @@ public interface IMyService : IService UnaryResult GetSingleValuesAsync(); UnaryResult GetBooleanValuesAsync(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -590,6 +658,7 @@ public async Task Return_ArrayFormatter_UserType() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -601,6 +670,9 @@ public interface IMyService : IService public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -617,6 +689,7 @@ public async Task KnownFormatters() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -640,6 +713,9 @@ public interface IMyService : IService public class MyResponse { } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateRawStreamingTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateRawStreamingTest.cs index b3302a514..032ce2321 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateRawStreamingTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateRawStreamingTest.cs @@ -11,6 +11,7 @@ public async Task StreamingResult() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; using System.Threading.Tasks; namespace TempProject @@ -21,6 +22,9 @@ public interface IMyService : IService Task> ServerStreamingAsync(); Task> DuplexStreamingAsync(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs index ac9664cf3..9f783f431 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs @@ -15,13 +15,17 @@ public async Task Return_UnaryResultNonGeneric() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyService : IService { UnaryResult A(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -36,13 +40,17 @@ public async Task Return_UnaryResultOfT() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyService : IService { UnaryResult A(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -57,13 +65,17 @@ public async Task Return_UnaryResultOfValueType() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyService : IService { UnaryResult A(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -78,13 +90,17 @@ public async Task Return_UnaryResultOfRefType() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyService : IService { UnaryResult A(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -99,13 +115,17 @@ public async Task Invalid_Return_TaskOfUnaryResultOfT() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyService : IService { Task> A(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -124,6 +144,7 @@ public async Task Return_StreamingResult() using System; using MessagePack; using MagicOnion; + using MagicOnion.Client; using System.Threading.Tasks; namespace TempProject @@ -134,6 +155,9 @@ public interface IMyService : IService Task> ServerStreamingAsync(); Task> DuplexStreamingAsync(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -148,6 +172,7 @@ public async Task Invalid_Return_NonGenerics() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -155,6 +180,9 @@ public interface IMyService : IService { int A(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -174,6 +202,7 @@ public async Task Invalid_Return_NonSupportedUnaryResultOfT() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -181,6 +210,9 @@ public interface IMyService : IService { UnaryResult> A(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; @@ -200,6 +232,7 @@ public async Task Invalid_Return_RawStreaming_NonTask() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -209,6 +242,9 @@ public interface IMyService : IService ServerStreamingResult ServerStreamingAsync(); DuplexStreamingResult DuplexStreamingAsync(); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs index e4eb020d6..3e7c39b68 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs @@ -15,7 +15,8 @@ public async Task Complex() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver @@ -38,6 +39,9 @@ public interface IMyHub : IStreamingHub public class MyObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -52,7 +56,8 @@ public async Task HubReceiver_Parameter_Zero() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver @@ -68,6 +73,9 @@ public interface IMyHub : IStreamingHub public class MyObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -82,7 +90,8 @@ public async Task HubReceiver_Parameter_One() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver @@ -98,6 +107,9 @@ public interface IMyHub : IStreamingHub public class MyObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -112,7 +124,8 @@ public async Task HubReceiver_Parameter_Many() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver @@ -128,6 +141,9 @@ public interface IMyHub : IStreamingHub public class MyObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -142,7 +158,8 @@ public async Task Return_Task() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver { } @@ -155,6 +172,9 @@ public interface IMyHub : IStreamingHub public class MyObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -169,7 +189,8 @@ public async Task Return_TaskOfT() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver { } @@ -182,6 +203,9 @@ public interface IMyHub : IStreamingHub public class MyObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -196,7 +220,8 @@ public async Task Return_ValueTask() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver { } @@ -209,6 +234,9 @@ public interface IMyHub : IStreamingHub public class MyObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -223,7 +251,8 @@ public async Task Return_ValueTaskOfT() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver { } @@ -236,6 +265,9 @@ public interface IMyHub : IStreamingHub public class MyObject { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -250,7 +282,8 @@ public async Task Invalid_Return_Void() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver { } @@ -258,6 +291,9 @@ public interface IMyHub : IStreamingHub { void A(); } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -280,7 +316,8 @@ public async Task Invalid_HubReceiver_ReturnsNotVoid() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver @@ -290,6 +327,9 @@ public interface IMyHubReceiver public interface IMyHub : IStreamingHub { } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -312,7 +352,8 @@ public async Task Parameter_Zero() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver { } @@ -320,6 +361,9 @@ public interface IMyHub : IStreamingHub { Task A(); } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -334,7 +378,8 @@ public async Task Parameter_One() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver { } @@ -342,6 +387,9 @@ public interface IMyHub : IStreamingHub { Task A(string arg0); } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -356,7 +404,8 @@ public async Task Parameter_Many() using System.Threading.Tasks; using MessagePack; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject { public interface IMyHubReceiver { } @@ -364,6 +413,9 @@ public interface IMyHub : IStreamingHub { Task A(string arg0, int arg1, bool arg2); } + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs index f8610e458..dd730a56a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs @@ -5,11 +5,34 @@ namespace MagicOnion.Client.SourceGenerator.Tests; public class GenerateTest { [Fact] - public async Task Generate() + public async Task NoGenerate() { var source = """ using MagicOnion; + using MagicOnion.Client; + + namespace MyApplication1; + + public interface IGreeterService : IService + { + UnaryResult HelloAsync(string name, int age); + UnaryResult PingAsync(); + UnaryResult CanGreetAsync(); + } + + // The source code has no `MagicOnionClientGeneration` attributed class. + """; + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task NotPartial() + { + var source = """ + using MagicOnion; + using MagicOnion.Client; + namespace MyApplication1; public interface IGreeterService : IService @@ -18,6 +41,32 @@ public interface IGreeterService : IService UnaryResult PingAsync(); UnaryResult CanGreetAsync(); } + + [MagicOnionClientGeneration(typeof(IGreeterService))] + class MagicOnionInitializer {} + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + + [Fact] + public async Task Generate() + { + var source = """ + using MagicOnion; + using MagicOnion.Client; + + namespace MyApplication1; + + public interface IGreeterService : IService + { + UnaryResult HelloAsync(string name, int age); + UnaryResult PingAsync(); + UnaryResult CanGreetAsync(); + } + + [MagicOnionClientGeneration(typeof(IGreeterService))] + partial class MagicOnionInitializer {} """; await MagicOnionSourceGeneratorVerifier.RunAsync(source); @@ -42,6 +91,7 @@ public async Task ImplicitUsings_PropertyGroup_Enable() ("IMyService.cs", """ using MagicOnion; + using MagicOnion.Client; using MessagePack; namespace MyNamespace; @@ -50,6 +100,10 @@ public interface IMyService : IService { UnaryResult A(Int32 arg0, IReadOnlyList arg1, FileMode arg2, ILookup arg3, ClientCertificateOption arg4, ApartmentState arg5, TaskCreationOptions arg6); } + + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} """ ), }; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateWithIfDirectiveTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateWithIfDirectiveTest.cs index e5a2bb467..aedffc299 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateWithIfDirectiveTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateWithIfDirectiveTest.cs @@ -12,6 +12,7 @@ public async Task Skip_Generation_StreamingHub_Interface() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -30,6 +31,9 @@ public interface IMyDebugHub : IStreamingHub Task A(int a); } #endif + + [MagicOnionClientGeneration(typeof(IMyHub))] + partial class MagicOnionInitializer {} } """; @@ -44,6 +48,7 @@ public async Task Skip_Generation_Service_Interface() using System.Threading.Tasks; using MessagePack; using MagicOnion; + using MagicOnion.Client; namespace TempProject { @@ -58,6 +63,9 @@ public interface IMyServiceForDebug : IService UnaryResult A(); } #endif + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} } """; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj index d66af386d..7f275bbb2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj @@ -36,10 +36,14 @@ + + + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs index 320fc01bf..e9601db1d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 8f331b997..e9de5e3bf 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs index 02359575c..72c77a027 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs index af5b9d3c3..813b732bd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs index 0f688e813..4550541bc 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs index d33cddac9..e125d7343 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs index 1ce8f0f6b..efc378dec 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs index af5b9d3c3..813b732bd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs index 602149428..e409451e6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs index d33cddac9..e125d7343 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs index 41008508e..6b2c4149a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 06cd0c444..96c9ff3b7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs index 3410c1516..d64f5e6c1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3040589d4..2d9e7995b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs index 941335d4d..8599620a6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3c79c288a..9d8d7e472 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs index e8a40f985..5cde72b7e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 55c37faba..591f96c0a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs index 4375d60d5..a57fe584a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c90a79bc7..05b661857 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs index 171887442..a632479e3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index cc422489f..dca4a743e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs index 9eff8cfe6..3f99d3cde 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 08b98f034..5cd8d9342 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs index 091c85867..bda0b687d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9291ee858..e77f4859a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs index bface7b68..4894f4a53 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9dc8bd9dd..5481704ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs index 1268aafbb..e795b7c4a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index d75be3682..b3911c5ca 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs index bcd2a61db..f7a707aeb 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 06cd0c444..96c9ff3b7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs index 1cfcb266e..b783d9355 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3040589d4..2d9e7995b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs index 37d89a229..3079ce057 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3c79c288a..9d8d7e472 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs index 58954cf2d..3ca2a66ec 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c90a79bc7..05b661857 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs index acccfc4ac..250c36d7d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index cc422489f..dca4a743e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs index 60235eb04..86e1e53bb 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 08b98f034..5cd8d9342 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs index a59c699c9..13abf834f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9291ee858..e77f4859a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs index 17cf6673c..c4bc909ab 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9dc8bd9dd..5481704ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs index 098ea7c74..c498a6a1a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index d75be3682..b3911c5ca 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs index afa8ef522..45646941f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 06cd0c444..96c9ff3b7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs index ad9ed2f98..ab77fe9d5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3040589d4..2d9e7995b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs index ab62dec7c..01b10cf5a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3c79c288a..9d8d7e472 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs index 7828bd3ac..bdef789ab 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 55c37faba..591f96c0a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs index 5b629a8db..e3c181ab4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c90a79bc7..05b661857 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs index 55c577e1f..53c25ace1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index cc422489f..dca4a743e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs index bf4d2c3e0..24f0ab254 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 08b98f034..5cd8d9342 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs index a0a19d7f0..22e953363 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9291ee858..e77f4859a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs index cb60efc51..cfe81fcca 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9dc8bd9dd..5481704ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs index 9e4bff44e..c62269fe8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index d75be3682..b3911c5ca 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs index 6d102ba1f..2fa2e4c92 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs index aac1cc80c..8fd3b618c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs index 3b8763340..02f41fd77 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a151121f3..86d62d4e1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs index faab412a3..c326b3ed5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3040589d4..2d9e7995b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs index dac960d2c..4e131be9f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3c79c288a..9d8d7e472 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs index d3a17c098..6246ef06c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c90a79bc7..05b661857 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs index 89e12c353..a7e9614ce 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index cc422489f..dca4a743e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs index 4e55d7e58..84d7083cf 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9291ee858..e77f4859a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs index d7f4a5f9d..2b6f4ee5b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9dc8bd9dd..5481704ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs index 5feea19d7..e1de294ec 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index d75be3682..b3911c5ca 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs index 9b3d6f6cc..e93b14f88 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 06cd0c444..96c9ff3b7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs index 6b79570ed..650c65637 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3040589d4..2d9e7995b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs index b13d816c0..f1ec4b953 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3c79c288a..9d8d7e472 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs index ba573232a..d3d46ca80 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 55c37faba..591f96c0a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs index 12ec62dd0..c2250994f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c90a79bc7..05b661857 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs index d1ac7c8c0..b1c453730 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index cc422489f..dca4a743e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs index 1875b9183..1ca89d0b1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 08b98f034..5cd8d9342 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs index 2974761ae..194da5cf7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9291ee858..e77f4859a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs index 9d2043b55..670eab6f0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9dc8bd9dd..5481704ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs index f93aa8d94..99c4e1636 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs index 3b1f6ec3a..e00ced4e7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs index d75be3682..b3911c5ca 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs index 131b08552..ddc2d0760 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c2daacb80..c75556a53 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs index 039a469c4..c8031683a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 75% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 43d539ba0..82d59980d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { @@ -37,9 +38,8 @@ internal static class MagicOnionResolverGetFormatterHelper static MagicOnionResolverGetFormatterHelper() { - lookup = new global::System.Collections.Generic.Dictionary(1) + lookup = new global::System.Collections.Generic.Dictionary(0) { - {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, }; } internal static object GetFormatter(Type t) @@ -52,7 +52,6 @@ internal static object GetFormatter(Type t) switch (key) { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); default: return null; } } @@ -64,9 +63,6 @@ internal static class TypeHints [MagicOnion.Resolvers.Preserve] internal static void Register() { - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); } } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..0c61a453d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 71% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 540728d45..82d59980d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,8 +1,9 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. -namespace __Generated__.Resolvers +namespace MagicOnion.Resolvers { using global::System; using global::MessagePack; @@ -37,9 +38,8 @@ internal static class MagicOnionResolverGetFormatterHelper static MagicOnionResolverGetFormatterHelper() { - lookup = new global::System.Collections.Generic.Dictionary(1) + lookup = new global::System.Collections.Generic.Dictionary(0) { - {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, }; } internal static object GetFormatter(Type t) @@ -52,21 +52,17 @@ internal static object GetFormatter(Type t) switch (key) { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); default: return null; } } } /// Type hints for Ahead-of-Time compilation. - [__Generated__.Resolvers.Preserve] + [MagicOnion.Resolvers.Preserve] internal static class TypeHints { - [__Generated__.Resolvers.Preserve] + [MagicOnion.Resolvers.Preserve] internal static void Register() { - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); } } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..0c61a453d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 66% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 00b1f9b21..82d59980d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { @@ -37,10 +38,8 @@ internal static class MagicOnionResolverGetFormatterHelper static MagicOnionResolverGetFormatterHelper() { - lookup = new global::System.Collections.Generic.Dictionary(2) + lookup = new global::System.Collections.Generic.Dictionary(0) { - {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, - {typeof(global::MyApplication1.MyGenericObject), 1 }, }; } internal static object GetFormatter(Type t) @@ -53,8 +52,6 @@ internal static object GetFormatter(Type t) switch (key) { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); - case 1: return new global::__UserDefined__.MessagePack.Formatters.MyApplication1.MyGenericObjectFormatter(); default: return null; } } @@ -66,10 +63,6 @@ internal static class TypeHints [MagicOnion.Resolvers.Preserve] internal static void Register() { - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); } } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..0c61a453d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..82d59980d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,68 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..0c61a453d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c2daacb80..c75556a53 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs index 039a469c4..c8031683a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs index ca33e7945..88538e5d8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs index ecb3d0ddd..b359fd595 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c2daacb80..c75556a53 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs index 3ea2f6932..cd5fe1481 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 894999b5f..209838045 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs index d2cf56797..573953e7f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c1998924c..7665e0853 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs index cbcc1c6e3..5a6fcb124 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c46a5679c..611b1d7c9 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs index f1e0709e0..98d474bd6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs index ac97f6005..b55ffb946 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs index 57a05b876..90cf75177 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a280fe173..206178b84 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs index aa345b00c..717ca2e2c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a280fe173..206178b84 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs index 18343b061..e80c0ee74 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..82d59980d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,68 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..0c61a453d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnion_Resolvers_MagicOnionResolver.g.cs new file mode 100644 index 000000000..82d59980d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -0,0 +1,68 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MagicOnion.Resolvers +{ + using global::System; + using global::MessagePack; + + partial class PreserveAttribute : global::System.Attribute {} + public class MagicOnionResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); + + MagicOnionResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + internal static class MagicOnionResolverGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MagicOnionResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [MagicOnion.Resolvers.Preserve] + internal static class TypeHints + { + [MagicOnion.Resolvers.Preserve] + internal static void Register() + { + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..0c61a453d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 3dd879564..df76de293 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs index 932ac2f28..e9d0397b7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs index c2daacb80..c75556a53 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs index 546b8d6f3..f1c516f3a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs index ca33e7945..88538e5d8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs index efa87d329..0bb64c138 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a280fe173..206178b84 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs index 6520b27f5..e697627d7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9c63814c3..46e5ab254 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs index f9892f622..7d192b047 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs index a280fe173..206178b84 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs index 879ad4ba4..9641b3f9c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 9c63814c3..46e5ab254 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs index 3430e3965..49a521457 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 73cac74da..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 4cda7d97d..3e8d6ef24 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs index 43d34fc7f..74cf52b60 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MyApplication1 diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..8854e5a3f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace MyApplication1 +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs index cfa638bb6..1bccdf1f1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs index 610f0f117..a8f6d1d14 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs index 32b5876a2..9dcc34ad4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs index 4d0f0c0ba..1db52f6fb 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Formatters { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index ff62233f2..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::MyNamespace.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyNamespace.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 75e0c983e..760aa474d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..fe00270e5 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace MyNamespace +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyNamespace.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyNamespace.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs index 6e540472e..b7281e086 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MyNamespace diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnion_Resolvers_MagicOnionResolver.g.cs similarity index 92% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 43d539ba0..3e8d6ef24 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { @@ -65,6 +66,8 @@ internal static class TypeHints internal static void Register() { _ = MagicOnionResolver.Instance.GetFormatter>(); + _ = MagicOnionResolver.Instance.GetFormatter(); + _ = MagicOnionResolver.Instance.GetFormatter(); _ = MagicOnionResolver.Instance.GetFormatter(); _ = MagicOnionResolver.Instance.GetFormatter(); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_GreeterServiceClient.g.cs similarity index 64% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_GreeterServiceClient.g.cs index 5ae7df74b..74cf52b60 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_GreeterServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MyApplication1 @@ -17,9 +18,13 @@ public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBa class ClientCore { public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker PingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker CanGreetAsync; public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) { this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + this.PingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "PingAsync", serializerProvider); + this.CanGreetAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "CanGreetAsync", serializerProvider); } } @@ -40,6 +45,10 @@ private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + public global::MagicOnion.UnaryResult PingAsync() + => this.core.PingAsync.InvokeUnaryNonGeneric(this, "IGreeterService/PingAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult CanGreetAsync() + => this.core.CanGreetAsync.InvokeUnary(this, "IGreeterService/CanGreetAsync", global::MessagePack.Nil.Default); } } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..8854e5a3f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace MyApplication1 +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 9e71bfffd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 894999b5f..209838045 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..59a55a748 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs index d2cf56797..573953e7f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 66b342050..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs index 894999b5f..209838045 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs @@ -1,6 +1,7 @@ // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. namespace MagicOnion.Resolvers { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..13a03cda1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + //public global::MessagePack.IFormatterResolver Resolver => core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs index 122fa65b6..ce0e1ffe9 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used +#pragma warning disable CS8019 // Unnecessary using directive. namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 73cac74da..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs deleted file mode 100644 index 5ae7df74b..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MyApplication1_GreeterServiceClient.g.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - - -namespace MyApplication1 -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); - } - } - - readonly ClientCore core; - - public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new GreeterServiceClient(options, core); - - public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) - => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); - } -} - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 564eb38a3..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs deleted file mode 100644 index 5ae7df74b..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MyApplication1_GreeterServiceClient.g.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - - -namespace MyApplication1 -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); - } - } - - readonly ClientCore core; - - public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new GreeterServiceClient(options, core); - - public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) - => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); - } -} - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 73cac74da..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs deleted file mode 100644 index b488d4e47..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MyApplication1_GreeterServiceClient.g.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - - -namespace MyApplication1 -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MyApplication1.MyGenericObject> HelloAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::MyApplication1.MyGenericObject>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); - } - } - - readonly ClientCore core; - - public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new GreeterServiceClient(options, core); - - public global::MagicOnion.UnaryResult> HelloAsync(global::System.String name, global::System.Int32 age) - => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); - } -} - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs deleted file mode 100644 index 5ae7df74b..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MyApplication1_GreeterServiceClient.g.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - - -namespace MyApplication1 -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); - } - } - - readonly ClientCore core; - - public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new GreeterServiceClient(options, core); - - public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) - => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); - } -} - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs deleted file mode 100644 index 8c933227f..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/__Generated___MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace __Generated__ -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs deleted file mode 100644 index 73cac74da..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs deleted file mode 100644 index a11d5a669..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnion_MagicOnionMemoryPackFormatterProvider.g.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete - -namespace MagicOnion -{ - using global::System; - using global::MemoryPack; - public class MagicOnionMemoryPackFormatterProvider - { - public static void RegisterFormatters() - { - global::MemoryPack.MemoryPackFormatterProvider.Register(new global::MagicOnion.Serialization.MemoryPack.DynamicArgumentTupleFormatter()); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs index 6998c5c17..dd9f04664 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs @@ -13,15 +13,21 @@ public void RunAndGenerate() { var (compilation, semanticModel) = CompilationHelper.Create( """ + #pragma warning disable CS8019 // Unnecessary using directive. + using System; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject; public interface IMyService : IService { UnaryResult HelloAsync(string name, int age); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} """); var sourceGenerator = new MagicOnionClientSourceGenerator(); @@ -30,20 +36,53 @@ public interface IMyService : IService driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true) ); - // Run generator for the first time. - driver = driver.RunGenerators(compilation); + // Run generator and update compilation + driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var newCompilation, out var diagnostics); + + Assert.DoesNotContain(diagnostics, x => x.Severity > DiagnosticSeverity.Info); + Assert.Empty(newCompilation.GetDiagnostics()); + var results = driver.GetRunResult().Results; var generatedTrees = driver.GetRunResult().GeneratedTrees; } [Fact] - public void RunAndGenerate_Service() + public void RunAndGenerate_External() { var (compilation, semanticModel) = CompilationHelper.Create( """ using System; using MagicOnion; + using MagicOnion.Client; + + namespace TempProject; + + [MagicOnionClientGeneration(typeof(SampleServiceDefinitions.Services.IGreeterService))] + partial class MagicOnionInitializer {} + """); + var sourceGenerator = new MagicOnionClientSourceGenerator(); + + GeneratorDriver driver = CSharpGeneratorDriver.Create( + generators: new[] { sourceGenerator.AsSourceGenerator() }, + driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true) + ); + + // Run generator and update compilation + driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var newCompilation, out var diagnostics); + + Assert.DoesNotContain(diagnostics, x => x.Severity > DiagnosticSeverity.Info); + Assert.DoesNotContain(newCompilation.GetDiagnostics(), x => x.Severity > DiagnosticSeverity.Info); + } + [Fact] + public void RunAndGenerate_Service() + { + var (compilation, semanticModel) = CompilationHelper.Create( + """ + using System; + using MagicOnion; + using MagicOnion.Client; + namespace TempProject; public interface IMyService : IService @@ -51,6 +90,9 @@ public interface IMyService : IService UnaryResult HelloAsync(string name, int age); UnaryResult HelloNullableAsync(string? name, int? age); } + + [MagicOnionClientGeneration(typeof(IMyService))] + partial class MagicOnionInitializer {} """); var sourceGenerator = new MagicOnionClientSourceGenerator(); @@ -63,6 +105,7 @@ public interface IMyService : IService driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var newCompilation, out var diagnostics); Assert.DoesNotContain(diagnostics, x => x.Severity > DiagnosticSeverity.Info); + Assert.DoesNotContain(newCompilation.GetDiagnostics(), x => x.Severity > DiagnosticSeverity.Info); } [Fact] @@ -73,7 +116,8 @@ public void RunAndGenerate_StreamingHub() using System; using System.Threading.Tasks; using MagicOnion; - + using MagicOnion.Client; + namespace TempProject; public interface IMyStreamingHub : IStreamingHub @@ -85,6 +129,9 @@ public interface IMyStreamingHub : IStreamingHub x.Severity > DiagnosticSeverity.Info); + Assert.DoesNotContain(newCompilation.GetDiagnostics(), x => x.Severity > DiagnosticSeverity.Info); } //[Fact] diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index 7f090ab2e..bf7fddbdc 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -1,4 +1,4 @@ -//#define WRITE_EXPECTED +#define WRITE_EXPECTED // https://github.com/MessagePack-CSharp/MessagePack-CSharp/blob/develop/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier%601%2BTest.cs // https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#unit-testing-of-generators diff --git a/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs b/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs new file mode 100644 index 000000000..681608ddf --- /dev/null +++ b/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs @@ -0,0 +1,7 @@ +using MagicOnion.Client; + +namespace MagicOnion.Integration.Tests; + +[MagicOnionClientGeneration(typeof(MagicOnionGeneratedClientInitializer))] +public partial class MagicOnionGeneratedClientInitializer +{} diff --git a/tests/samples/SampleServiceDefinitions/SampleServiceDefinitions.csproj b/tests/samples/SampleServiceDefinitions/SampleServiceDefinitions.csproj new file mode 100644 index 000000000..cfbb899f3 --- /dev/null +++ b/tests/samples/SampleServiceDefinitions/SampleServiceDefinitions.csproj @@ -0,0 +1,13 @@ + + + + netstandard2.1 + enable + latest + + + + + + + diff --git a/tests/samples/SampleServiceDefinitions/Services/IGreeterService.cs b/tests/samples/SampleServiceDefinitions/Services/IGreeterService.cs new file mode 100644 index 000000000..1124540f1 --- /dev/null +++ b/tests/samples/SampleServiceDefinitions/Services/IGreeterService.cs @@ -0,0 +1,10 @@ +using MagicOnion; + +namespace SampleServiceDefinitions.Services; + +public interface IGreeterService : IService +{ + UnaryResult HelloAsync(string name, int age); + UnaryResult PingAsync(); + UnaryResult CanGreetAsync(); +} From b8d2530f2fbc8d490391081da82d31ae41336145 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 14:56:30 +0900 Subject: [PATCH 33/66] WIP --- .../SerializationInfoCollector.cs | 1 - .../CodeGen/ISerializerFormatterGenerator.cs | 4 +- .../CodeGen/MagicOnionInitializerGenerator.cs | 7 +- ...emoryPackFormatterRegistrationGenerator.cs | 86 +++--- .../MessagePackEnumFormatterGenerator.cs | 50 ++-- .../MessagePackFormatterResolverGenerator.cs | 253 +++++++++--------- .../SerializationFormatterCodeGenContext.cs | 9 +- .../MagicOnionClientGenerator.cs | 14 +- ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...er_Formatters_MyClass_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 78 ++++++ ...03_TempProject_MagicOnionInitializer.g.cs} | 3 +- ... => 0004_TempProject_MyServiceClient.g.cs} | 0 ...on_Formatters_MyClass_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 75 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 75 ++++++ ...03_TempProject_MagicOnionInitializer.g.cs} | 3 +- ... => 0004_TempProject_MyServiceClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 72 ----- ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 78 ++++++ ...03_TempProject_MagicOnionInitializer.g.cs} | 3 +- ... => 0004_TempProject_MyServiceClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 75 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 75 ++++++ ...03_TempProject_MagicOnionInitializer.g.cs} | 3 +- ... => 0004_TempProject_MyServiceClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 72 ----- ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 78 ++++++ ...003_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0004_TempProject_MyServiceClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 75 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...02_TempProject_MagicOnionInitializer.g.cs} | 3 +- ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...02_TempProject_MagicOnionInitializer.g.cs} | 3 +- ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 76 ++++++ ...02_TempProject_MagicOnionInitializer.g.cs} | 3 +- ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 73 ----- ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 78 ++++++ ...03_TempProject_MagicOnionInitializer.g.cs} | 3 +- ...g.cs => 0004_TempProject_MyHubClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 75 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 76 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 73 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 92 +++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 79 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 76 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 81 ++++++ ...003_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0004_TempProject_MyHubClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 78 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 76 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 73 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 76 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 73 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 92 +++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 79 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 76 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 81 ++++++ ...003_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0004_TempProject_MyHubClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 78 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 76 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 73 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 78 ++++++ ...003_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0004_TempProject_MyHubClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 75 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 76 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 73 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 92 +++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 79 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 76 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 81 ++++++ ...003_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0004_TempProject_MyHubClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 78 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 111 ++++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 108 -------- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 86 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 83 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 76 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 73 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 76 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 73 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 92 +++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 79 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 76 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 81 ++++++ ...003_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0004_TempProject_MyServiceClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 78 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 76 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 73 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 78 ++++++ ...003_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0004_TempProject_MyServiceClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 75 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 76 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 73 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 80 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 77 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 92 +++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 89 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 79 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 76 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...nitializer_Formatters_MyEnumFormatter.g.cs | 29 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 81 ++++++ ...003_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0004_TempProject_MyServiceClient.g.cs} | 0 ...MagicOnion_Formatters_MyEnumFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 78 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 71 +++++ ...02_TempProject_MagicOnionInitializer.g.cs} | 3 +- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 68 ----- ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 71 +++++ ...02_TempProject_MagicOnionInitializer.g.cs} | 3 +- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 68 ----- ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 71 +++++ ...02_TempProject_MagicOnionInitializer.g.cs} | 3 +- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 68 ----- ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 71 +++++ ...02_TempProject_MagicOnionInitializer.g.cs} | 3 +- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 68 ----- ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 72 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 69 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 81 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 78 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 78 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 75 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 71 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 83 ++++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 68 ----- .../TempProject_MagicOnionInitializer.g.cs | 82 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 71 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 83 ++++++ ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 68 ----- .../TempProject_MagicOnionInitializer.g.cs | 82 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 78 ++++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 75 ------ .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 72 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 69 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 72 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 69 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 72 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 69 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ..._MyApplication1_GreeterServiceClient.g.cs} | 0 ...ation1_MagicOnionInitializer_Resolver.g.cs | 78 ++++++ ...MyApplication1_MagicOnionInitializer.g.cs} | 3 +- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 75 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...er_Formatters_ApartmentStateFormatter.g.cs | 29 ++ ...ters_ClientCertificateOptionFormatter.g.cs | 29 ++ ...tializer_Formatters_FileModeFormatter.g.cs | 29 ++ ...rmatters_TaskCreationOptionsFormatter.g.cs | 29 ++ ...espace_MagicOnionInitializer_Resolver.g.cs | 95 +++++++ ...06_MyNamespace_MagicOnionInitializer.g.cs} | 3 +- ... => 0007_MyNamespace_MyServiceClient.g.cs} | 0 ...on_Formatters_ApartmentStateFormatter.g.cs | 23 -- ...ters_ClientCertificateOptionFormatter.g.cs | 23 -- ...gicOnion_Formatters_FileModeFormatter.g.cs | 23 -- ...rmatters_TaskCreationOptionsFormatter.g.cs | 23 -- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 92 ------- ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ..._MyApplication1_GreeterServiceClient.g.cs} | 0 ...ation1_MagicOnionInitializer_Resolver.g.cs | 78 ++++++ ...MyApplication1_MagicOnionInitializer.g.cs} | 3 +- ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 75 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ... => 0003_TempProject_MyServiceClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...roject_MagicOnionInitializer_Resolver.g.cs | 73 +++++ ...002_TempProject_MagicOnionInitializer.g.cs | 87 ++++++ ...g.cs => 0003_TempProject_MyHubClient.g.cs} | 0 ...gicOnion_Resolvers_MagicOnionResolver.g.cs | 70 ----- .../TempProject_MagicOnionInitializer.g.cs | 86 ------ ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...OnionClientSourceGeneratorAttributes.g.cs} | 0 ...OnionClientSourceGeneratorAttributes.g.cs} | 0 .../MagicOnionSourceGeneratorVerifier.cs | 32 ++- 514 files changed, 12853 insertions(+), 12397 deletions(-) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/{GenerateEnumFormatter_Parameter_Nullable/TempProject_MagicOnionInitializer.g.cs => GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs} (98%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/{TempProject_MyServiceClient.g.cs => 0004_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/{GenerateEnumFormatter_Return/TempProject_MagicOnionInitializer.g.cs => GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs} (98%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/{TempProject_MyServiceClient.g.cs => 0004_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/{GenerateEnumFormatter_Nested/TempProject_MagicOnionInitializer.g.cs => GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs} (98%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/{TempProject_MyServiceClient.g.cs => 0004_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/{GenerateEnumFormatter_Parameter/TempProject_MagicOnionInitializer.g.cs => GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs} (98%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/{TempProject_MyServiceClient.g.cs => 0004_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/{TempProject_MyServiceClient.g.cs => 0004_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/{TempProject_MagicOnionInitializer.g.cs => 0002_TempProject_MagicOnionInitializer.g.cs} (98%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/{TempProject_MagicOnionInitializer.g.cs => 0002_TempProject_MagicOnionInitializer.g.cs} (98%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/{TempProject_MagicOnionInitializer.g.cs => 0002_TempProject_MagicOnionInitializer.g.cs} (98%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/{TempProject_MagicOnionInitializer.g.cs => 0003_TempProject_MagicOnionInitializer.g.cs} (98%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/{TempProject_MyHubClient.g.cs => 0004_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/{TempProject_MyHubClient.g.cs => 0004_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/{TempProject_MyHubClient.g.cs => 0004_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/{TempProject_MyHubClient.g.cs => 0004_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/{TempProject_MyHubClient.g.cs => 0004_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/{TempProject_MyServiceClient.g.cs => 0004_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/{TempProject_MyServiceClient.g.cs => 0004_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/{TempProject_MyServiceClient.g.cs => 0004_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/{TempProject_MagicOnionInitializer.g.cs => 0002_TempProject_MagicOnionInitializer.g.cs} (98%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/{TempProject_MagicOnionInitializer.g.cs => 0002_TempProject_MagicOnionInitializer.g.cs} (98%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/{TempProject_MagicOnionInitializer.g.cs => 0002_TempProject_MagicOnionInitializer.g.cs} (98%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/{TempProject_MagicOnionInitializer.g.cs => 0002_TempProject_MagicOnionInitializer.g.cs} (98%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/{MyApplication1_GreeterServiceClient.g.cs => 0001_MyApplication1_GreeterServiceClient.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/{MyApplication1_MagicOnionInitializer.g.cs => 0003_MyApplication1_MagicOnionInitializer.g.cs} (98%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{MyNamespace_MagicOnionInitializer.g.cs => 0006_MyNamespace_MagicOnionInitializer.g.cs} (98%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{MyNamespace_MyServiceClient.g.cs => 0007_MyNamespace_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/{MyApplication1_GreeterServiceClient.g.cs => 0001_MyApplication1_GreeterServiceClient.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/{MyApplication1_MagicOnionInitializer.g.cs => 0003_MyApplication1_MagicOnionInitializer.g.cs} (98%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnion_Resolvers_MagicOnionResolver.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/{TempProject_MyServiceClient.g.cs => 0003_TempProject_MyServiceClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/{TempProject_MyHubClient.g.cs => 0003_TempProject_MyHubClient.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MagicOnionInitializer.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/{MagicOnionClientSourceGeneratorAttributes.g.cs => 0000_MagicOnionClientSourceGeneratorAttributes.g.cs} (100%) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs index 99765a7b6..e01365e7b 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs @@ -102,7 +102,6 @@ public MagicOnionSerializationInfoCollection Collect(IEnumerable core; + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; """); + if (!options.DisableAutoRegister) { writer.WriteLine($$""" diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs index 22dafd848..751023372 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs @@ -4,69 +4,71 @@ namespace MagicOnion.Client.SourceGenerator.CodeGen; internal class MemoryPackFormatterRegistrationGenerator : ISerializerFormatterGenerator { - public string Build(SerializationFormatterCodeGenContext ctx) + public string Build(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { - EmitPreamble(ctx); - EmitBody(ctx); - EmitPostscript(ctx); + EmitPreamble(generationContext, ctx); + EmitBody(generationContext, ctx); + EmitPostscript(generationContext, ctx); return ctx.GetWrittenText(); } - static void EmitPreamble(SerializationFormatterCodeGenContext ctx) + static void EmitPreamble(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { - ctx.TextWriter.WriteLines(""" - // - #pragma warning disable CS0618 // 'member' is obsolete: 'text' - #pragma warning disable CS0612 // 'member' is obsolete - #pragma warning disable CS8019 // Unnecessary using directive. + ctx.TextWriter.WriteLine(""" + // + #pragma warning disable CS0618 // 'member' is obsolete: 'text' + #pragma warning disable CS0612 // 'member' is obsolete + #pragma warning disable CS8019 // Unnecessary using directive. - """); + """); } - static void EmitBody(SerializationFormatterCodeGenContext ctx) + static void EmitBody(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { - ctx.TextWriter.WriteLines($$""" - namespace {{ctx.Namespace}} + if (!string.IsNullOrEmpty(generationContext.Namespace)) { - using global::System; - using global::MemoryPack; - """); - - using (ctx.TextWriter.BeginIndent()) - { - EmitRegister(ctx); + ctx.TextWriter.WriteLine($$""" + namespace {{generationContext.Namespace}} + { + """); } + ctx.TextWriter.WriteLine($$""" + using global::System; + using global::MemoryPack; + """); - ctx.TextWriter.WriteLines($$""" + EmitRegister(generationContext, ctx); + + if (!string.IsNullOrEmpty(generationContext.Namespace)) + { + ctx.TextWriter.WriteLine($$""" + } + """); } - """); } - static void EmitRegister(SerializationFormatterCodeGenContext ctx) + static void EmitRegister(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { - ctx.TextWriter.WriteLines($$""" - public class {{ctx.InitializerName}} + ctx.TextWriter.WriteLine($$""" + partial class {{generationContext.InitializerPartialTypeName}} + { + public static void RegisterMemoryPackFormatters() + { + """); + foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) { - public static void RegisterFormatters() - { - """); - using (ctx.TextWriter.BeginIndent(2)) - { - foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) - { - ctx.TextWriter.WriteLines($$""" - global::MemoryPack.MemoryPackFormatterProvider.Register(new {{(resolverInfo.FormatterName.StartsWith("global::") || string.IsNullOrWhiteSpace(ctx.FormatterNamespace) ? "" : ctx.FormatterNamespace + ".") + resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}); - """); - } - } - ctx.TextWriter.WriteLines($$""" - } + ctx.TextWriter.WriteLine($$""" + global::MemoryPack.MemoryPackFormatterProvider.Register(new {{(resolverInfo.FormatterName.StartsWith("global::") || string.IsNullOrWhiteSpace(ctx.FormatterNamespace) ? "" : ctx.FormatterNamespace + ".") + resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}); + """); } - """); + ctx.TextWriter.WriteLine($$""" + } + } + """); } - static void EmitPostscript(SerializationFormatterCodeGenContext ctx) + static void EmitPostscript(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs index 0227f6408..cc8ef0ba9 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs @@ -4,7 +4,7 @@ namespace MagicOnion.Client.SourceGenerator.CodeGen; internal class MessagePackEnumFormatterGenerator { - public static string Build(string @namespace, IEnumerable enumSerializationInfoSet) + public static string Build(GenerationContext context, IEnumerable enumSerializationInfoSet) { var writer = new StringWriter(); writer.WriteLine($$""" @@ -15,35 +15,53 @@ public static string Build(string @namespace, IEnumerable """); - writer.WriteLine($$""" - namespace {{@namespace}} + if (!string.IsNullOrEmpty(context.Namespace)) + { + writer.WriteLine($$""" + namespace {{context.Namespace}} + { """); + } + writer.WriteLine($$""" - { using global::System; using global::MessagePack; + partial class {{context.InitializerPartialTypeName}} + { + static class MessagePackEnumFormatters + { """); + foreach (var info in enumSerializationInfoSet) { writer.WriteLine($$""" - public sealed class {{info.FormatterName}} : global::MessagePack.Formatters.IMessagePackFormatter<{{info.FullName}}> - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, {{info.FullName}} value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write(({{info.UnderlyingType}})value); - } - - public {{info.FullName}} Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return ({{info.FullName}})reader.Read{{info.UnderlyingType}}(); - } - } + public sealed class {{info.FormatterName}} : global::MessagePack.Formatters.IMessagePackFormatter<{{info.FullName}}> + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, {{info.FullName}} value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write(({{info.UnderlyingType}})value); + } + + public {{info.FullName}} Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return ({{info.FullName}})reader.Read{{info.UnderlyingType}}(); + } + } """); } + writer.WriteLine($$""" + } + } + """); + + if (!string.IsNullOrEmpty(context.Namespace)) + { + writer.WriteLine($$""" } """); + } return writer.ToString(); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs index 9b51824cd..66ef3b3d7 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs @@ -1,170 +1,173 @@ -using MagicOnion.Client.SourceGenerator.Internal; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator.CodeGen; internal class MessagePackFormatterResolverGenerator : ISerializerFormatterGenerator { - public string Build(SerializationFormatterCodeGenContext ctx) + public string Build(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { - EmitPreamble(ctx); - EmitBody(ctx); - EmitPostscript(ctx); + EmitPreamble(generationContext, ctx); + EmitBody(generationContext, ctx); + EmitPostscript(generationContext, ctx); return ctx.GetWrittenText(); } - static void EmitPreamble(SerializationFormatterCodeGenContext ctx) + static void EmitPreamble(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { - ctx.TextWriter.WriteLines(""" - // - #pragma warning disable CS0618 // 'member' is obsolete: 'text' - #pragma warning disable CS0612 // 'member' is obsolete - #pragma warning disable CS8019 // Unnecessary using directive. + ctx.TextWriter.WriteLine(""" + // + #pragma warning disable CS0618 // 'member' is obsolete: 'text' + #pragma warning disable CS0612 // 'member' is obsolete + #pragma warning disable CS8019 // Unnecessary using directive. - """); + """); } - static void EmitBody(SerializationFormatterCodeGenContext ctx) + static void EmitBody(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { - ctx.TextWriter.WriteLines($$""" - namespace {{ctx.Namespace}} + if (!string.IsNullOrEmpty(generationContext.Namespace)) { - using global::System; - using global::MessagePack; + ctx.TextWriter.WriteLine($$""" + namespace {{generationContext.Namespace}} + { + """); + } + ctx.TextWriter.WriteLine($$""" + using global::System; + using global::MessagePack; - partial class PreserveAttribute : global::System.Attribute {} - """); + partial class {{generationContext.InitializerPartialTypeName}} + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + """); - using (ctx.TextWriter.BeginIndent()) - { - EmitResolver(ctx); - EmitGetFormatterHelper(ctx); - EmitTypeHints(ctx); - } + EmitResolver(ctx); + EmitGetFormatterHelper(ctx); + EmitTypeHints(ctx); - ctx.TextWriter.WriteLines($$""" + ctx.TextWriter.WriteLine($$""" + } + """); + + if (!string.IsNullOrEmpty(generationContext.Namespace)) + { + ctx.TextWriter.WriteLine($$""" + } + """); } - """); } static void EmitResolver(SerializationFormatterCodeGenContext ctx) { - ctx.TextWriter.WriteLines($$""" - public class {{ctx.InitializerName}} : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new {{ctx.InitializerName}}(); - - {{ctx.InitializerName}}() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = {{ctx.InitializerName}}GetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) + ctx.TextWriter.WriteLine($$""" + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } } - } - } - } - """); + """); } static void EmitGetFormatterHelper(SerializationFormatterCodeGenContext ctx) { - ctx.TextWriter.WriteLines($$""" - internal static class {{ctx.InitializerName}}GetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static {{ctx.InitializerName}}GetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary({{ctx.FormatterRegistrations.Count}}) - { - """); - using (ctx.TextWriter.BeginIndent()) - { - using (ctx.TextWriter.BeginIndent()) - { - using (ctx.TextWriter.BeginIndent()) - { - foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) + ctx.TextWriter.WriteLine($$""" + static class MessagePackGeneratedGetFormatterHelper { - ctx.TextWriter.WriteLines($$""" - {typeof({{resolverInfo.FullName}}), {{index}} }, - """); - } - } // lookup = new ... - ctx.TextWriter.WriteLine("};"); - } // static {{ctx.ResolverName}}GetFormatterHelper() - ctx.TextWriter.WriteLine("}"); + static readonly global::System.Collections.Generic.Dictionary lookup; - ctx.TextWriter.WriteLines($$""" - internal static object GetFormatter(Type t) + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary({{ctx.FormatterRegistrations.Count}}) + { + """); + foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) + { + ctx.TextWriter.WriteLine($$""" + {typeof({{resolverInfo.FullName}}), {{index}}}, + """); + } + ctx.TextWriter.WriteLine($$""" + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + """); + foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) + { + if (resolverInfo is EnumSerializationInfo) { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { + // Use EnumFormatter generated by MagicOnion.Client.SourceGenerator + ctx.TextWriter.WriteLine($$""" + case {{index}}: return new MessagePackEnumFormatters.{{resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}; """); - using (ctx.TextWriter.BeginIndent()) + } + else { - using (ctx.TextWriter.BeginIndent()) - { - foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) - { - ctx.TextWriter.WriteLines($$""" - case {{index}}: return new {{(resolverInfo.FormatterName.StartsWith("global::") || string.IsNullOrWhiteSpace(ctx.FormatterNamespace) ? "" : ctx.FormatterNamespace + ".") + resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}; - """); - } - ctx.TextWriter.WriteLine("default: return null;"); - } // switch (key) - ctx.TextWriter.WriteLine("}"); - } // internal static object GetFormatter(Type t) - ctx.TextWriter.WriteLine("}"); + // Use formatter generated by MessagePack generator. + ctx.TextWriter.WriteLine($$""" + case {{index}}: return new {{(resolverInfo.FormatterName.StartsWith("global::") || string.IsNullOrWhiteSpace(ctx.FormatterNamespace) ? "" : ctx.FormatterNamespace + ".") + resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}; + """); + } } - ctx.TextWriter.WriteLine("}"); + ctx.TextWriter.WriteLine($$""" + default: return null; + } + } + } + """); } - + static void EmitTypeHints(SerializationFormatterCodeGenContext ctx) { - ctx.TextWriter.WriteLines($$""" - /// Type hints for Ahead-of-Time compilation. - [{{ctx.Namespace}}.Preserve] - internal static class TypeHints - { - [{{ctx.Namespace}}.Preserve] - internal static void Register() - { - """); - using (ctx.TextWriter.BeginIndent()) + ctx.TextWriter.WriteLine($$""" + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + """); + foreach (var typeHint in ctx.TypeHints) { - using (ctx.TextWriter.BeginIndent()) - { - foreach (var typeHint in ctx.TypeHints) - { - ctx.TextWriter.WriteLines($$""" - _ = {{ctx.InitializerName}}.Instance.GetFormatter<{{typeHint.FullName}}>(); - """); - } - } - } - ctx.TextWriter.WriteLines($$""" - } + ctx.TextWriter.WriteLine($$""" + _ = MessagePackGeneratedResolver.Instance.GetFormatter<{{typeHint.FullName}}>(); + """); } - """); + ctx.TextWriter.WriteLine($$""" + } + } + """); } - static void EmitPostscript(SerializationFormatterCodeGenContext ctx) + + static void EmitPostscript(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs index 76f3431e4..ea25b4058 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs @@ -7,24 +7,19 @@ public class SerializationFormatterCodeGenContext { readonly StringWriter underlyingWriter; - public string Namespace { get; } public string FormatterNamespace { get; } - public string InitializerName { get; } public IReadOnlyList FormatterRegistrations { get; } public IReadOnlyList TypeHints { get; } - public IndentedTextWriter TextWriter { get; } + public TextWriter TextWriter => underlyingWriter; - public SerializationFormatterCodeGenContext(string @namespace, string formatterNamespace, string initializerName, IReadOnlyList formatterRegistrations, IReadOnlyList typeHints) + public SerializationFormatterCodeGenContext(string formatterNamespace, IReadOnlyList formatterRegistrations, IReadOnlyList typeHints) { - Namespace = @namespace; FormatterNamespace = formatterNamespace; - InitializerName = initializerName; FormatterRegistrations = formatterRegistrations; TypeHints = typeHints; underlyingWriter = new StringWriter(); - TextWriter = new IndentedTextWriter(underlyingWriter); } public string GetWrittenText() => underlyingWriter.ToString(); diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs index d84222542..72d4a0cb6 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs @@ -18,22 +18,20 @@ public static class MagicOnionClientGenerator var formattersNamespace = namespaceDot + "Formatters"; // Configure serialization - (ISerializationFormatterNameMapper Mapper, string Namespace, string InitializerName, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) + (ISerializationFormatterNameMapper Mapper, string Namespace, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) serialization = options.Serializer switch { GeneratorOptions.SerializerType.MemoryPack => ( Mapper: new MemoryPackFormatterNameMapper(), Namespace: options.Namespace, - InitializerName: "MagicOnionMemoryPackFormatterProvider", Generator: new MemoryPackFormatterRegistrationGenerator(), EnumFormatterGenerator: _ => string.Empty ), GeneratorOptions.SerializerType.MessagePack => ( Mapper: new MessagePackFormatterNameMapper(options.MessagePackFormatterNamespace), Namespace: namespaceDot + "Resolvers", - InitializerName: "MagicOnionResolver", Generator: new MessagePackFormatterResolverGenerator(), - EnumFormatterGenerator: x => MessagePackEnumFormatterGenerator.Build(formattersNamespace, x) + EnumFormatterGenerator: x => MessagePackEnumFormatterGenerator.Build(context, x) ), _ => throw new NotImplementedException(), }; @@ -45,17 +43,17 @@ public static class MagicOnionClientGenerator cancellationToken.ThrowIfCancellationRequested(); - var formatterCodeGenContext = new SerializationFormatterCodeGenContext(serialization.Namespace, formattersNamespace, serialization.InitializerName, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); - var resolverTexts = serialization.Generator.Build(formatterCodeGenContext); + var formatterCodeGenContext = new SerializationFormatterCodeGenContext(formattersNamespace, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); + var resolverTexts = serialization.Generator.Build(context, formatterCodeGenContext); cancellationToken.ThrowIfCancellationRequested(); outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName), MagicOnionInitializerGenerator.Build(context.Namespace, context.InitializerPartialTypeName, options, serviceCollection))); - outputs.Add((GeneratePathFromNamespaceAndTypeName(formatterCodeGenContext.Namespace, formatterCodeGenContext.InitializerName), resolverTexts)); + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".Resolver"), resolverTexts)); foreach (var enumSerializationInfo in serializationInfoCollection.Enums) { - outputs.Add((GeneratePathFromNamespaceAndTypeName(formattersNamespace, enumSerializationInfo.FormatterName), serialization.EnumFormatterGenerator(new []{ enumSerializationInfo }))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".Formatters." + enumSerializationInfo.FormatterName), serialization.EnumFormatterGenerator(new []{ enumSerializationInfo }))); } foreach (var service in serviceCollection.Services) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs new file mode 100644 index 000000000..e77b2d472 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyClass_MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyClass.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyClass.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyClass.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..84231fe0d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Nullable), 0}, + {typeof(global::TempProject.MyClass.MyEnum), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.NullableFormatter(); + case 1: return new MessagePackEnumFormatters.MyClass_MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs index 59a55a748..74314a900 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs deleted file mode 100644 index e9601db1d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Formatters_MyClass_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyClass_MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyClass.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyClass.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyClass.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index e9de5e3bf..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::System.Nullable), 0 }, - {typeof(global::TempProject.MyClass.MyEnum), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.NullableFormatter(); - case 1: return new MagicOnion.Formatters.MyClass_MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..6436a4796 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,75 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyEnum), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs index 59a55a748..74314a900 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 813b732bd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::TempProject.MyEnum), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..e8f13eb93 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Nullable), 0}, + {typeof(global::TempProject.MyEnum), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.NullableFormatter(); + case 1: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs index 59a55a748..74314a900 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index e125d7343..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::System.Nullable), 0 }, - {typeof(global::TempProject.MyEnum), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.NullableFormatter(); - case 1: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..6436a4796 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,75 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyEnum), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs index 59a55a748..74314a900 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 813b732bd..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::TempProject.MyEnum), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..e8f13eb93 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Nullable), 0}, + {typeof(global::TempProject.MyEnum), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.NullableFormatter(); + case 1: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index e125d7343..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::System.Nullable), 0 }, - {typeof(global::TempProject.MyEnum), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.NullableFormatter(); - case 1: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..8fb1d4a66 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs index 13a03cda1..390875c8b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 96c9ff3b7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..dbf14c6ca --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 13a03cda1..390875c8b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 2d9e7995b..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..c306c1595 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyResponse[]), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 13a03cda1..390875c8b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 9d8d7e472..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::TempProject.MyResponse[]), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ArrayFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..ac8cfb352 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyEnum), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 13a03cda1..390875c8b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 591f96c0a..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyEnum), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..8ac488062 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Collections.Generic.List), 0}, + {typeof(global::System.Collections.Generic.List), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + case 1: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 05b661857..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::System.Collections.Generic.List), 0 }, - {typeof(global::System.Collections.Generic.List), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - case 1: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..cc5556914 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::System.Collections.Generic.List), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index dca4a743e..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::System.Collections.Generic.List), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..4b5eb605e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 5cd8d9342..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..5a58eef11 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,92 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyGenericObject>>), 2}, + {typeof(global::TempProject.MyGenericObject>>), 3}, + {typeof(global::TempProject.MyGenericObject>), 4}, + {typeof(global::TempProject.MyGenericObject), 5}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index e77f4859a..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,89 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(6) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyGenericObject>>), 2 }, - {typeof(global::TempProject.MyGenericObject>>), 3 }, - {typeof(global::TempProject.MyGenericObject>), 4 }, - {typeof(global::TempProject.MyGenericObject), 5 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); - case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); - case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..cece63905 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyNestedGenericObject[]), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 5481704ba..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyNestedGenericObject[]), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.ArrayFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..7d5c94552 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,81 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyEnum), 2}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0004_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0004_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index b3911c5ca..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(3) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyEnum), 2 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..8fb1d4a66 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 96c9ff3b7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..dbf14c6ca --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 2d9e7995b..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..c306c1595 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyResponse[]), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 9d8d7e472..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::TempProject.MyResponse[]), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ArrayFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..8ac488062 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Collections.Generic.List), 0}, + {typeof(global::System.Collections.Generic.List), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + case 1: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 05b661857..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::System.Collections.Generic.List), 0 }, - {typeof(global::System.Collections.Generic.List), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - case 1: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..cc5556914 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::System.Collections.Generic.List), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index dca4a743e..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::System.Collections.Generic.List), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..4b5eb605e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 5cd8d9342..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..5a58eef11 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,92 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyGenericObject>>), 2}, + {typeof(global::TempProject.MyGenericObject>>), 3}, + {typeof(global::TempProject.MyGenericObject>), 4}, + {typeof(global::TempProject.MyGenericObject), 5}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index e77f4859a..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,89 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(6) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyGenericObject>>), 2 }, - {typeof(global::TempProject.MyGenericObject>>), 3 }, - {typeof(global::TempProject.MyGenericObject>), 4 }, - {typeof(global::TempProject.MyGenericObject), 5 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); - case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); - case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..cece63905 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyNestedGenericObject[]), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 5481704ba..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyNestedGenericObject[]), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.ArrayFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..7d5c94552 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,81 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyEnum), 2}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index b3911c5ca..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(3) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyEnum), 2 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..8fb1d4a66 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 96c9ff3b7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..dbf14c6ca --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 2d9e7995b..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..c306c1595 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyResponse[]), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 9d8d7e472..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::TempProject.MyResponse[]), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ArrayFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..ac8cfb352 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyEnum), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0004_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0004_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 591f96c0a..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyEnum), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..8ac488062 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Collections.Generic.List), 0}, + {typeof(global::System.Collections.Generic.List), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + case 1: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 05b661857..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::System.Collections.Generic.List), 0 }, - {typeof(global::System.Collections.Generic.List), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - case 1: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..cc5556914 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::System.Collections.Generic.List), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index dca4a743e..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::System.Collections.Generic.List), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..4b5eb605e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 5cd8d9342..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..5a58eef11 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,92 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyGenericObject>>), 2}, + {typeof(global::TempProject.MyGenericObject>>), 3}, + {typeof(global::TempProject.MyGenericObject>), 4}, + {typeof(global::TempProject.MyGenericObject), 5}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index e77f4859a..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,89 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(6) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyGenericObject>>), 2 }, - {typeof(global::TempProject.MyGenericObject>>), 3 }, - {typeof(global::TempProject.MyGenericObject>), 4 }, - {typeof(global::TempProject.MyGenericObject), 5 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); - case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); - case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..cece63905 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyNestedGenericObject[]), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 5481704ba..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyNestedGenericObject[]), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.ArrayFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..7d5c94552 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,81 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyEnum), 2}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index b3911c5ca..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(3) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyEnum), 2 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..fa21effde --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,111 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(12) + { + {typeof(global::System.Collections.Generic.Dictionary), 0}, + {typeof(global::System.Collections.Generic.ICollection), 1}, + {typeof(global::System.Collections.Generic.IDictionary), 2}, + {typeof(global::System.Collections.Generic.IEnumerable), 3}, + {typeof(global::System.Collections.Generic.IList), 4}, + {typeof(global::System.Collections.Generic.IReadOnlyCollection), 5}, + {typeof(global::System.Collections.Generic.IReadOnlyDictionary), 6}, + {typeof(global::System.Collections.Generic.IReadOnlyList), 7}, + {typeof(global::System.Collections.Generic.List), 8}, + {typeof(global::System.Collections.Generic.List), 9}, + {typeof(global::System.Linq.IGrouping), 10}, + {typeof(global::System.Linq.ILookup), 11}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.DictionaryFormatter(); + case 1: return new global::MessagePack.Formatters.InterfaceCollectionFormatter2(); + case 2: return new global::MessagePack.Formatters.InterfaceDictionaryFormatter(); + case 3: return new global::MessagePack.Formatters.InterfaceEnumerableFormatter(); + case 4: return new global::MessagePack.Formatters.InterfaceListFormatter2(); + case 5: return new global::MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter(); + case 6: return new global::MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter(); + case 7: return new global::MessagePack.Formatters.InterfaceReadOnlyListFormatter(); + case 8: return new global::MessagePack.Formatters.ListFormatter(); + case 9: return new global::MessagePack.Formatters.ListFormatter(); + case 10: return new global::MessagePack.Formatters.InterfaceGroupingFormatter(); + case 11: return new global::MessagePack.Formatters.InterfaceLookupFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 8fd3b618c..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,108 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(12) - { - {typeof(global::System.Collections.Generic.Dictionary), 0 }, - {typeof(global::System.Collections.Generic.ICollection), 1 }, - {typeof(global::System.Collections.Generic.IDictionary), 2 }, - {typeof(global::System.Collections.Generic.IEnumerable), 3 }, - {typeof(global::System.Collections.Generic.IList), 4 }, - {typeof(global::System.Collections.Generic.IReadOnlyCollection), 5 }, - {typeof(global::System.Collections.Generic.IReadOnlyDictionary), 6 }, - {typeof(global::System.Collections.Generic.IReadOnlyList), 7 }, - {typeof(global::System.Collections.Generic.List), 8 }, - {typeof(global::System.Collections.Generic.List), 9 }, - {typeof(global::System.Linq.IGrouping), 10 }, - {typeof(global::System.Linq.ILookup), 11 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.DictionaryFormatter(); - case 1: return new global::MessagePack.Formatters.InterfaceCollectionFormatter2(); - case 2: return new global::MessagePack.Formatters.InterfaceDictionaryFormatter(); - case 3: return new global::MessagePack.Formatters.InterfaceEnumerableFormatter(); - case 4: return new global::MessagePack.Formatters.InterfaceListFormatter2(); - case 5: return new global::MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter(); - case 6: return new global::MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter(); - case 7: return new global::MessagePack.Formatters.InterfaceReadOnlyListFormatter(); - case 8: return new global::MessagePack.Formatters.ListFormatter(); - case 9: return new global::MessagePack.Formatters.ListFormatter(); - case 10: return new global::MessagePack.Formatters.InterfaceGroupingFormatter(); - case 11: return new global::MessagePack.Formatters.InterfaceLookupFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..713968d21 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,86 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + {typeof(global::System.Collections.Generic.IReadOnlyList), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyGenericObject), 2}, + {typeof(global::TempProject.MyGenericObject), 3}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.InterfaceReadOnlyListFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 86d62d4e1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(4) - { - {typeof(global::System.Collections.Generic.IReadOnlyList), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyGenericObject), 2 }, - {typeof(global::TempProject.MyGenericObject), 3 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.InterfaceReadOnlyListFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..dbf14c6ca --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 2d9e7995b..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..c306c1595 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyResponse[]), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 9d8d7e472..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::TempProject.MyResponse[]), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ArrayFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..8ac488062 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Collections.Generic.List), 0}, + {typeof(global::System.Collections.Generic.List), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + case 1: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 05b661857..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::System.Collections.Generic.List), 0 }, - {typeof(global::System.Collections.Generic.List), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - case 1: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..cc5556914 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::System.Collections.Generic.List), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index dca4a743e..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::System.Collections.Generic.List), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..5a58eef11 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,92 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyGenericObject>>), 2}, + {typeof(global::TempProject.MyGenericObject>>), 3}, + {typeof(global::TempProject.MyGenericObject>), 4}, + {typeof(global::TempProject.MyGenericObject), 5}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index e77f4859a..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,89 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(6) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyGenericObject>>), 2 }, - {typeof(global::TempProject.MyGenericObject>>), 3 }, - {typeof(global::TempProject.MyGenericObject>), 4 }, - {typeof(global::TempProject.MyGenericObject), 5 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); - case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); - case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..cece63905 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyNestedGenericObject[]), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 5481704ba..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyNestedGenericObject[]), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.ArrayFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..7d5c94552 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,81 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyEnum), 2}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index b3911c5ca..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(3) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyEnum), 2 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..8fb1d4a66 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 96c9ff3b7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..dbf14c6ca --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 2d9e7995b..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..c306c1595 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::TempProject.MyResponse[]), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 9d8d7e472..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::TempProject.MyResponse[]), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ArrayFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..ac8cfb352 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyEnum), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 591f96c0a..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyEnum), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..8ac488062 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::System.Collections.Generic.List), 0}, + {typeof(global::System.Collections.Generic.List), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + case 1: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 05b661857..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::System.Collections.Generic.List), 0 }, - {typeof(global::System.Collections.Generic.List), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - case 1: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..cc5556914 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::System.Collections.Generic.List), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.ListFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index dca4a743e..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::System.Collections.Generic.List), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..4b5eb605e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,80 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 5cd8d9342..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..5a58eef11 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,92 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyGenericObject>>), 2}, + {typeof(global::TempProject.MyGenericObject>>), 3}, + {typeof(global::TempProject.MyGenericObject>), 4}, + {typeof(global::TempProject.MyGenericObject), 5}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); + case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index e77f4859a..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,89 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(6) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyGenericObject>>), 2 }, - {typeof(global::TempProject.MyGenericObject>>), 3 }, - {typeof(global::TempProject.MyGenericObject>), 4 }, - {typeof(global::TempProject.MyGenericObject), 5 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); - case 3: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>>(); - case 4: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 5: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..cece63905 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyNestedGenericObject[]), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.ArrayFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 5481704ba..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyNestedGenericObject[]), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.ArrayFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs new file mode 100644 index 000000000..0106a7ff3 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..7d5c94552 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,81 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + {typeof(global::TempProject.MyGenericObject), 0}, + {typeof(global::TempProject.MyGenericObject>), 1}, + {typeof(global::TempProject.MyEnum), 2}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); + case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); + case 2: return new MessagePackEnumFormatters.MyEnumFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>>(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs deleted file mode 100644 index e00ced4e7..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Formatters_MyEnumFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index b3911c5ca..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(3) - { - {typeof(global::TempProject.MyGenericObject), 0 }, - {typeof(global::TempProject.MyGenericObject>), 1 }, - {typeof(global::TempProject.MyEnum), 2 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter(); - case 1: return new global::MessagePack.Formatters.TempProject.MyGenericObjectFormatter>(); - case 2: return new MagicOnion.Formatters.MyEnumFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>>(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..c3fd4e177 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index c75556a53..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..469652ca8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,71 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs index 0c61a453d..d97a8bdb2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 82d59980d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..469652ca8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,71 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index 0c61a453d..d97a8bdb2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 82d59980d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..469652ca8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,71 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs index 0c61a453d..d97a8bdb2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 82d59980d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..469652ca8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,71 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index 0c61a453d..d97a8bdb2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 82d59980d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..c3fd4e177 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index c75556a53..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..2525378cb --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,72 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 88538e5d8..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..c3fd4e177 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index c75556a53..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..eea855741 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 209838045..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..7507c8651 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 7665e0853..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..0af36aae5 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,81 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, + {typeof(global::MagicOnion.DynamicArgumentTuple), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::TempProject.MyObject), default(global::System.String), default(global::System.Int32)); + case 1: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::TempProject.MyObject), default(global::System.String)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 611b1d7c9..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, - {typeof(global::MagicOnion.DynamicArgumentTuple), 1 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::TempProject.MyObject), default(global::System.String), default(global::System.Int32)); - case 1: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::TempProject.MyObject), default(global::System.String)); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..03e854624 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::TempProject.MyObject), default(global::System.Int32), default(global::System.String)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index b55ffb946..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::TempProject.MyObject), default(global::System.Int32), default(global::System.String)); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..1531302d2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 206178b84..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..1531302d2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 206178b84..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..469652ca8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,71 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d97a8bdb2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 82d59980d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 0c61a453d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..469652ca8 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,71 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..d97a8bdb2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,83 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 82d59980d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 0c61a453d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..85602e542 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32), default(global::System.Boolean)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index df76de293..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32), default(global::System.Boolean)); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..c3fd4e177 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index c75556a53..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..2525378cb --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,72 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 88538e5d8..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..1531302d2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 206178b84..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..16d29ad3f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,72 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 46e5ab254..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..1531302d2 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 206178b84..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..16d29ad3f --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,72 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 46e5ab254..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_GreeterServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..0ffa2328e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyApplication1 +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs index 8854e5a3f..3327da194 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MyApplication1_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace MyApplication1 using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 3e8d6ef24..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs new file mode 100644 index 000000000..c50a99a1e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyNamespace +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class ApartmentStateFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Threading.ApartmentState value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.Threading.ApartmentState Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::System.Threading.ApartmentState)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs new file mode 100644 index 000000000..9f1fb8edf --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyNamespace +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class ClientCertificateOptionFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Net.Http.ClientCertificateOption value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.Net.Http.ClientCertificateOption Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::System.Net.Http.ClientCertificateOption)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs new file mode 100644 index 000000000..7f206d20a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyNamespace +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class FileModeFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.IO.FileMode value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.IO.FileMode Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::System.IO.FileMode)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs new file mode 100644 index 000000000..95853d73b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyNamespace +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static class MessagePackEnumFormatters + { + public sealed class TaskCreationOptionsFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Threading.Tasks.TaskCreationOptions value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.Threading.Tasks.TaskCreationOptions Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::System.Threading.Tasks.TaskCreationOptions)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..c63f6ebf1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,95 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyNamespace +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(7) + { + {typeof(global::MagicOnion.DynamicArgumentTuple, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>), 0}, + {typeof(global::System.Collections.Generic.IReadOnlyList), 1}, + {typeof(global::System.Linq.ILookup), 2}, + {typeof(global::System.IO.FileMode), 3}, + {typeof(global::System.Net.Http.ClientCertificateOption), 4}, + {typeof(global::System.Threading.ApartmentState), 5}, + {typeof(global::System.Threading.Tasks.TaskCreationOptions), 6}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>(default(global::System.Int32), default(global::System.Collections.Generic.IReadOnlyList), default(global::System.IO.FileMode), default(global::System.Linq.ILookup), default(global::System.Net.Http.ClientCertificateOption), default(global::System.Threading.ApartmentState), default(global::System.Threading.Tasks.TaskCreationOptions)); + case 1: return new global::MessagePack.Formatters.InterfaceReadOnlyListFormatter(); + case 2: return new global::MessagePack.Formatters.InterfaceLookupFormatter(); + case 3: return new MessagePackEnumFormatters.FileModeFormatter(); + case 4: return new MessagePackEnumFormatters.ClientCertificateOptionFormatter(); + case 5: return new MessagePackEnumFormatters.ApartmentStateFormatter(); + case 6: return new MessagePackEnumFormatters.TaskCreationOptionsFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs index fe00270e5..802025152 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace MyNamespace using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MyNamespace_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs deleted file mode 100644 index 1bccdf1f1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ApartmentStateFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class ApartmentStateFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Threading.ApartmentState value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::System.Threading.ApartmentState Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::System.Threading.ApartmentState)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs deleted file mode 100644 index a8f6d1d14..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_ClientCertificateOptionFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class ClientCertificateOptionFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Net.Http.ClientCertificateOption value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::System.Net.Http.ClientCertificateOption Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::System.Net.Http.ClientCertificateOption)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs deleted file mode 100644 index 9dcc34ad4..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_FileModeFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class FileModeFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.IO.FileMode value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::System.IO.FileMode Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::System.IO.FileMode)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs deleted file mode 100644 index 1db52f6fb..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Formatters_TaskCreationOptionsFormatter.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Formatters -{ - using global::System; - using global::MessagePack; - - public sealed class TaskCreationOptionsFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Threading.Tasks.TaskCreationOptions value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::System.Threading.Tasks.TaskCreationOptions Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::System.Threading.Tasks.TaskCreationOptions)reader.ReadInt32(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 760aa474d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,92 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(7) - { - {typeof(global::MagicOnion.DynamicArgumentTuple, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>), 0 }, - {typeof(global::System.Collections.Generic.IReadOnlyList), 1 }, - {typeof(global::System.Linq.ILookup), 2 }, - {typeof(global::System.IO.FileMode), 3 }, - {typeof(global::System.Net.Http.ClientCertificateOption), 4 }, - {typeof(global::System.Threading.ApartmentState), 5 }, - {typeof(global::System.Threading.Tasks.TaskCreationOptions), 6 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>(default(global::System.Int32), default(global::System.Collections.Generic.IReadOnlyList), default(global::System.IO.FileMode), default(global::System.Linq.ILookup), default(global::System.Net.Http.ClientCertificateOption), default(global::System.Threading.ApartmentState), default(global::System.Threading.Tasks.TaskCreationOptions)); - case 1: return new global::MessagePack.Formatters.InterfaceReadOnlyListFormatter(); - case 2: return new global::MessagePack.Formatters.InterfaceLookupFormatter(); - case 3: return new MagicOnion.Formatters.FileModeFormatter(); - case 4: return new MagicOnion.Formatters.ClientCertificateOptionFormatter(); - case 5: return new MagicOnion.Formatters.ApartmentStateFormatter(); - case 6: return new MagicOnion.Formatters.TaskCreationOptionsFormatter(); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_GreeterServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..0ffa2328e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyApplication1 +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs similarity index 98% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs index 8854e5a3f..3327da194 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MyApplication1_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -10,6 +10,8 @@ namespace MyApplication1 using global::MagicOnion; using global::MagicOnion.Client; + partial class PreserveAttribute : global::System.Attribute {} + partial class MagicOnionInitializer { bool isRegistered = false; @@ -17,7 +19,6 @@ partial class MagicOnionInitializer public static MagicOnionInitializer Instance { get; } = new(); - //public global::MessagePack.IFormatterResolver Resolver => core; public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 3e8d6ef24..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::MagicOnion.DynamicArgumentTuple), 0 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter>(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..eea855741 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..74314a900 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::TempProject.IMyService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 209838045..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 59a55a748..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::TempProject.IMyService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..eea855741 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,73 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace TempProject +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..390875c8b --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace TempProject +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) + { + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + } + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0003_TempProject_MyHubClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MyHubClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0003_TempProject_MyHubClient.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs deleted file mode 100644 index 209838045..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/MagicOnion_Resolvers_MagicOnionResolver.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - - partial class PreserveAttribute : global::System.Attribute {} - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(0) - { - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [MagicOnion.Resolvers.Preserve] - internal static class TypeHints - { - [MagicOnion.Resolvers.Preserve] - internal static void Register() - { - _ = MagicOnionResolver.Instance.GetFormatter(); - _ = MagicOnionResolver.Instance.GetFormatter(); - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MagicOnionInitializer.g.cs deleted file mode 100644 index 13a03cda1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/TempProject_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace TempProject -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class MagicOnionInitializer - { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static MagicOnionInitializer Instance { get; } = new(); - - //public global::MessagePack.IFormatterResolver Resolver => core; - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - static void Register() => Instance.TryRegisterProviderFactory(); - - public bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/MagicOnionClientSourceGeneratorAttributes.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index bf7fddbdc..747f7afd6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -1,15 +1,17 @@ -#define WRITE_EXPECTED +//#define WRITE_EXPECTED // https://github.com/MessagePack-CSharp/MessagePack-CSharp/blob/develop/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier%601%2BTest.cs // https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#unit-testing-of-generators using System.Collections.Immutable; +using System.ComponentModel.DataAnnotations; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Rename; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; using Microsoft.CodeAnalysis.Text; @@ -123,14 +125,24 @@ void AddGeneratedReferenceSources() { var prefix = $"{typeof(Test).Assembly.GetName().Name}.Resources.{Path.GetFileNameWithoutExtension(testFile)}.{testMethod}."; - foreach (var resName in typeof(Test).Assembly.GetManifestResourceNames().OrderBy(x => x)) + var referenceFiles = typeof(Test).Assembly.GetManifestResourceNames() + .Where(x => x.StartsWith(prefix)) + .Select(resName => + { + using var stream = typeof(Test).Assembly.GetManifestResourceStream(resName) ?? throw new InvalidOperationException(); + using var reader = new StreamReader(stream); + var source = reader.ReadToEnd(); + var fileNameWithIndex = resName.Substring(prefix.Length); + var index = int.Parse(fileNameWithIndex.Substring(0, 4)); + var fileName = fileNameWithIndex.Substring(4 + 1); + + return (Index: index, FileName: fileName, Source: source); + }) + .OrderBy(x => x.Index); + + foreach (var (_, fileName, source) in referenceFiles) { - if (!resName.StartsWith(prefix)) continue; - - using var stream = typeof(Test).Assembly.GetManifestResourceStream(resName) ?? throw new InvalidOperationException(); - using var reader = new StreamReader(stream); - var source = reader.ReadToEnd(); - TestState.GeneratedSources.Add((typeof(MagicOnion.Client.SourceGenerator.MagicOnionClientSourceGenerator), resName.Substring(prefix.Length), SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha1))); + TestState.GeneratedSources.Add((typeof(MagicOnion.Client.SourceGenerator.MagicOnionClientSourceGenerator), fileName, SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha1))); } } @@ -145,9 +157,9 @@ protected override Task RunImplAsync(CancellationToken cancellationToken) var (compilation, diagnostics) = await base.GetProjectCompilationAsync(project, verifier, cancellationToken); var resourceDirectory = Path.Combine(Path.GetDirectoryName(testFile)!, "Resources", Path.GetFileNameWithoutExtension(testFile), testMethod); - foreach (var syntaxTree in compilation.SyntaxTrees.Skip(project.DocumentIds.Count)) + foreach (var (syntaxTree, index) in compilation.SyntaxTrees.Skip(project.DocumentIds.Count).Select((x, i) => (x, i))) { - WriteTreeToDiskIfNecessary(syntaxTree, resourceDirectory, ""); + WriteTreeToDiskIfNecessary(syntaxTree, resourceDirectory, $"{index:0000}_"); } return (compilation, diagnostics); From 22e425a94906a9fdc8aa5ff42a5bb70439a40516 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 15:12:19 +0900 Subject: [PATCH 34/66] Remove System.CodeDom reference --- .../StaticMagicOnionClientGenerator.cs | 188 +++++++++--------- .../MagicOnion.Client.SourceGenerator.csproj | 1 - .../0004_TempProject_MyServiceClient.g.cs | 13 +- .../0004_TempProject_MyServiceClient.g.cs | 13 +- .../0004_TempProject_MyServiceClient.g.cs | 13 +- .../0004_TempProject_MyServiceClient.g.cs | 13 +- .../0004_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0004_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0004_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0004_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- ...1_MyApplication1_GreeterServiceClient.g.cs | 13 +- .../0007_MyNamespace_MyServiceClient.g.cs | 13 +- ...1_MyApplication1_GreeterServiceClient.g.cs | 13 +- .../0003_TempProject_MyServiceClient.g.cs | 13 +- 36 files changed, 301 insertions(+), 330 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs index d87ef542e..9d00f4426 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs @@ -9,7 +9,7 @@ public class StaticMagicOnionClientGenerator { class ServiceClientBuildContext { - public ServiceClientBuildContext(MagicOnionServiceInfo service, IndentedTextWriter textWriter) + public ServiceClientBuildContext(MagicOnionServiceInfo service, TextWriter textWriter) { Service = service; TextWriter = textWriter; @@ -17,13 +17,12 @@ public ServiceClientBuildContext(MagicOnionServiceInfo service, IndentedTextWrit public MagicOnionServiceInfo Service { get; } - public IndentedTextWriter TextWriter { get; } + public TextWriter TextWriter { get; } } public static string Build(IEnumerable services) { - var baseWriter = new StringWriter(); - var textWriter = new IndentedTextWriter(baseWriter); + var textWriter = new StringWriter(); EmitHeader(textWriter); @@ -36,40 +35,39 @@ public static string Build(IEnumerable services) EmitPostscript(buildContext); } - return baseWriter.ToString(); + return textWriter.ToString(); } - static void EmitHeader(IndentedTextWriter textWriter) + static void EmitHeader(TextWriter textWriter) { - textWriter.WriteLines(""" - // - #pragma warning disable CS0618 // 'member' is obsolete: 'text' - #pragma warning disable CS0612 // 'member' is obsolete - #pragma warning disable CS8019 // Unnecessary using directive. - - """); - textWriter.WriteLine(); + textWriter.WriteLine(""" + // + #pragma warning disable CS0618 // 'member' is obsolete: 'text' + #pragma warning disable CS0612 // 'member' is obsolete + #pragma warning disable CS8019 // Unnecessary using directive. + + """); } static void EmitPreamble(ServiceClientBuildContext ctx) { - ctx.TextWriter.WriteLines($$""" - namespace {{ctx.Service.ServiceType.Namespace}} - { - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - """); - ctx.TextWriter.Indent++; - ctx.TextWriter.WriteLine(); + ctx.TextWriter.WriteLine($$""" + namespace {{ctx.Service.ServiceType.Namespace}} + { + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + """); } static void EmitPostscript(ServiceClientBuildContext ctx) { - ctx.TextWriter.Indent--; - ctx.TextWriter.WriteLine("}"); + ctx.TextWriter.WriteLine(""" + } + """); ctx.TextWriter.WriteLine(); } @@ -79,59 +77,61 @@ static void EmitServiceClientClass(ServiceClientBuildContext ctx) // public class {ServiceName}Client : MagicOnionClientBase<{ServiceName}>, {ServiceName} // { // - ctx.TextWriter.WriteLines($$""" - [global::MagicOnion.Ignore] - public class {{ctx.Service.GetClientName()}} : global::MagicOnion.Client.MagicOnionClientBase<{{ctx.Service.ServiceType.FullName}}>, {{ctx.Service.ServiceType.FullName}} - { - """); - using (ctx.TextWriter.BeginIndent()) - { - // class ClientCore { ... } - EmitClientCore(ctx); - // private readonly ClientCore core; ... - EmitFields(ctx); - // public {ServiceName}Client(MagicOnionClientOptions options, IMagicOnionSerializerProvider serializerProvider) : base(options) { ... } - // private {ServiceName}Client(MagicOnionClientOptions options, ClientCore core) : base(options) { ... } - EmitConstructor(ctx); - // protected override ClientBase<{ServiceName}> Clone(MagicOnionClientOptions options) => new {ServiceName}Client(options, core); - EmitClone(ctx); - // public {MethodType}Result MethodName(TArg1 arg1, TArg2 arg2, ...) => this.core.MethodName.Invoke{MethodType}(this, "ServiceName/MethodName", new DynamicArgumentTuple(arg1, arg2, ...)); ... - EmitServiceMethods(ctx); - } - ctx.TextWriter.WriteLine("}"); + ctx.TextWriter.WriteLine($$""" + [global::MagicOnion.Ignore] + public class {{ctx.Service.GetClientName()}} : global::MagicOnion.Client.MagicOnionClientBase<{{ctx.Service.ServiceType.FullName}}>, {{ctx.Service.ServiceType.FullName}} + { + """); + // class ClientCore { ... } + EmitClientCore(ctx); + // private readonly ClientCore core; ... + EmitFields(ctx); + // public {ServiceName}Client(MagicOnionClientOptions options, IMagicOnionSerializerProvider serializerProvider) : base(options) { ... } + // private {ServiceName}Client(MagicOnionClientOptions options, ClientCore core) : base(options) { ... } + EmitConstructor(ctx); + // protected override ClientBase<{ServiceName}> Clone(MagicOnionClientOptions options) => new {ServiceName}Client(options, core); + EmitClone(ctx); + // public {MethodType}Result MethodName(TArg1 arg1, TArg2 arg2, ...) => this.core.MethodName.Invoke{MethodType}(this, "ServiceName/MethodName", new DynamicArgumentTuple(arg1, arg2, ...)); ... + EmitServiceMethods(ctx); + + ctx.TextWriter.WriteLine(""" + } + """); // } } static void EmitClone(ServiceClientBuildContext ctx) { - ctx.TextWriter.WriteLines($""" - protected override global::MagicOnion.Client.MagicOnionClientBase<{ctx.Service.ServiceType.Name}> Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new {ctx.Service.GetClientName()}(options, core); - """); + ctx.TextWriter.WriteLine($""" + protected override global::MagicOnion.Client.MagicOnionClientBase<{ctx.Service.ServiceType.Name}> Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new {ctx.Service.GetClientName()}(options, core); + """); ctx.TextWriter.WriteLine(); } static void EmitConstructor(ServiceClientBuildContext ctx) { - ctx.TextWriter.WriteLines($$""" - public {{ctx.Service.GetClientName()}}(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } + ctx.TextWriter.WriteLine($$""" + public {{ctx.Service.GetClientName()}}(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } - private {{ctx.Service.GetClientName()}}(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - """); - ctx.TextWriter.WriteLine(); + private {{ctx.Service.GetClientName()}}(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + """); } static void EmitFields(ServiceClientBuildContext ctx) { // private readonly ClientCore core; - ctx.TextWriter.WriteLine("readonly ClientCore core;"); - ctx.TextWriter.WriteLine(); + ctx.TextWriter.WriteLine(""" + readonly ClientCore core; + + """); } static void EmitServiceMethods(ServiceClientBuildContext ctx) @@ -166,9 +166,9 @@ _ when (method.MethodType != MethodType.Unary && method.MethodType != MethodType }; var hasNonGenericUnaryResult = method.MethodReturnType == MagicOnionTypeInfo.KnownTypes.MagicOnion_UnaryResult; - ctx.TextWriter.WriteLines($""" - public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) - => this.core.{method.MethodName}.Invoke{method.MethodType}{(hasNonGenericUnaryResult ? "NonGeneric" : "")}(this, "{method.Path}"{invokeRequestParameters}); + ctx.TextWriter.WriteLine($""" + public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) + => this.core.{method.MethodName}.Invoke{method.MethodType}{(hasNonGenericUnaryResult ? "NonGeneric" : "")}(this, "{method.Path}"{invokeRequestParameters}); """); } } @@ -189,33 +189,39 @@ static void EmitClientCore(ServiceClientBuildContext ctx) */ // class ClientCore { - ctx.TextWriter.WriteLine("class ClientCore"); - ctx.TextWriter.WriteLine("{"); - using (ctx.TextWriter.BeginIndent()) + ctx.TextWriter.WriteLine(""" + class ClientCore + { + """); + + // public RawMethodInvoker MethodName; + foreach (var method in ctx.Service.Methods) { - // public RawMethodInvoker MethodName; - foreach (var method in ctx.Service.Methods) - { - ctx.TextWriter.WriteLine($"public global::MagicOnion.Client.Internal.RawMethodInvoker<{method.RequestType.FullName}, {method.ResponseType.FullName}> {method.MethodName};"); - } + ctx.TextWriter.WriteLine($$""" + public global::MagicOnion.Client.Internal.RawMethodInvoker<{{method.RequestType.FullName}}, {{method.ResponseType.FullName}}> {{method.MethodName}}; + """); + } - // public ClientCore(IMagicOnionSerializerProvider serializerProvider) { - ctx.TextWriter.WriteLine("public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider)"); - ctx.TextWriter.WriteLine("{"); - using (ctx.TextWriter.BeginIndent()) - { - // MethodName = RawMethodInvoker.Create_XXXType_XXXType(MethodType, ServiceName, MethodName, serializerProvider); - foreach (var method in ctx.Service.Methods) - { - var createMethodVariant = $"{(method.RequestType.IsValueType ? "Value" : "Ref")}Type_{(method.ResponseType.IsValueType ? "Value" : "Ref")}Type"; - ctx.TextWriter.WriteLine($"this.{method.MethodName} = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_{createMethodVariant}<{method.RequestType.FullName}, {method.ResponseType.FullName}>(global::Grpc.Core.MethodType.{method.MethodType}, \"{method.ServiceName}\", \"{method.MethodName}\", serializerProvider);"); - } - } - ctx.TextWriter.WriteLine("}"); - // } + // public ClientCore(IMagicOnionSerializerProvider serializerProvider) { + ctx.TextWriter.WriteLine(""" + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + """); + + // MethodName = RawMethodInvoker.Create_XXXType_XXXType(MethodType, ServiceName, MethodName, serializerProvider); + foreach (var method in ctx.Service.Methods) + { + var createMethodVariant = $"{(method.RequestType.IsValueType ? "Value" : "Ref")}Type_{(method.ResponseType.IsValueType ? "Value" : "Ref")}Type"; + ctx.TextWriter.WriteLine($$""" + this.{{method.MethodName}} = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_{{createMethodVariant}}<{{method.RequestType.FullName}}, {{method.ResponseType.FullName}}>(global::Grpc.Core.MethodType.{{method.MethodType}}, "{{method.ServiceName}}", "{{method.MethodName}}", serializerProvider); + """); } + ctx.TextWriter.WriteLine(""" + } + } + + """); + // } // } - ctx.TextWriter.WriteLine("}"); - ctx.TextWriter.WriteLine(); } } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index f0febe512..079ae98fe 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -20,7 +20,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs index 72c77a027..06289231b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetEnumAsync(global::System.Nullable a) => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs index 4550541bc..fb95094b4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetEnumAsync(global::TempProject.MyEnum a) => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs index efc378dec..6c753abac 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetEnumAsync(global::System.Nullable a) => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs index e409451e6..699033b27 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetEnumAsync() => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs index 6b2c4149a..7102af582 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult> GetEnumAsync() => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs index 02f41fd77..34475c9ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -43,22 +42,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.MethodIGrouping = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIGrouping", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult> MethodList(global::System.Collections.Generic.List args) => this.core.MethodList.InvokeUnary(this, "IMyService/MethodList", args); public global::MagicOnion.UnaryResult> MethodIList() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs index c326b3ed5..463a5fa97 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -27,22 +26,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult A(global::TempProject.MyGenericObject a) => this.core.A.InvokeUnary(this, "IMyService/A", a); public global::MagicOnion.UnaryResult B(global::TempProject.MyGenericObject a) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index 4e131be9f..59427b189 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -31,22 +30,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetBooleanValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetBooleanValuesAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetStringValuesAsync(global::System.String[] arg0) => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", arg0); public global::MagicOnion.UnaryResult GetIntValuesAsync(global::System.Int32[] arg0) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index 6246ef06c..9867a7b28 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetValuesAsync(global::TempProject.MyResponse[] arg0) => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index a7e9614ce..b3f3d7767 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -25,22 +24,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetStringValuesAsync(global::System.Collections.Generic.List arg0) => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", arg0); public global::MagicOnion.UnaryResult GetIntValuesAsync(global::System.Collections.Generic.List arg0) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index 84d7083cf..edbd8856f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetValuesAsync(global::System.Collections.Generic.List arg0) => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs index 2b6f4ee5b..a0798b9c7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -27,22 +26,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult A(global::TempProject.MyGenericObject> a) => this.core.A.InvokeUnary(this, "IMyService/A", a); public global::MagicOnion.UnaryResult B(global::TempProject.MyGenericObject>> a) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs index e1de294ec..486815da8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetValuesAsync(global::TempProject.MyGenericObject arg0) => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs index e93b14f88..bbe889b41 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetEnumAsync(global::TempProject.MyGenericObject> arg0) => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", arg0); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs index 650c65637..f1959bbd7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -25,22 +24,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult> A() => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); public global::MagicOnion.UnaryResult> B() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index f1ec4b953..e706eaa13 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -31,22 +30,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetBooleanValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetBooleanValuesAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetStringValuesAsync() => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", global::MessagePack.Nil.Default); public global::MagicOnion.UnaryResult GetIntValuesAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index d3d46ca80..5f2703b5e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult GetValuesAsync() => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs index c2250994f..16add03ce 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult> GetEnumAsync() => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index b1c453730..b8b80226e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -25,22 +24,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult> GetStringValuesAsync() => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", global::MessagePack.Nil.Default); public global::MagicOnion.UnaryResult> GetIntValuesAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index 1ca89d0b1..266cc6d1b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult> GetValuesAsync() => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs index 194da5cf7..104f38d02 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -25,22 +24,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult> A() => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); public global::MagicOnion.UnaryResult> B() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs index 670eab6f0..6e926b04e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -27,22 +26,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult>> A() => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); public global::MagicOnion.UnaryResult>>> B() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs index 99c4e1636..338c33d8d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult> GetValuesAsync() => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs index ddc2d0760..80a8b1c2c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult>> GetEnumAsync() => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs index c8031683a..67b55e64f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -27,22 +26,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.DuplexStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.DuplexStreaming, "IMyService", "DuplexStreamingAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::System.Threading.Tasks.Task> ClientStreamingAsync() => this.core.ClientStreamingAsync.InvokeClientStreaming(this, "IMyService/ClientStreamingAsync"); public global::System.Threading.Tasks.Task> ServerStreamingAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs index c8031683a..67b55e64f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -27,22 +26,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.DuplexStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.DuplexStreaming, "IMyService", "DuplexStreamingAsync", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::System.Threading.Tasks.Task> ClientStreamingAsync() => this.core.ClientStreamingAsync.InvokeClientStreaming(this, "IMyService/ClientStreamingAsync"); public global::System.Threading.Tasks.Task> ServerStreamingAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs index b359fd595..0e3178033 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult A() => this.core.A.InvokeUnaryNonGeneric(this, "IMyService/A", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs index cd5fe1481..e1c34dd8d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult A() => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs index 573953e7f..8c6701050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult A() => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs index 5a6fcb124..1e83af852 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult A() => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs index 74cf52b60..25bf3b16b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace MyApplication1 { using global::System; @@ -11,7 +10,7 @@ namespace MyApplication1 using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService { @@ -27,22 +26,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.CanGreetAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "CanGreetAsync", serializerProvider); } } - + readonly ClientCore core; - + public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new GreeterServiceClient(options, core); - + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); public global::MagicOnion.UnaryResult PingAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs index b7281e086..36b4527b1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace MyNamespace { using global::System; @@ -11,7 +10,7 @@ namespace MyNamespace using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyNamespace.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult A(global::System.Int32 arg0, global::System.Collections.Generic.IReadOnlyList arg1, global::System.IO.FileMode arg2, global::System.Linq.ILookup arg3, global::System.Net.Http.ClientCertificateOption arg4, global::System.Threading.ApartmentState arg5, global::System.Threading.Tasks.TaskCreationOptions arg6) => this.core.A.InvokeUnary(this, "IMyService/A", new global::MagicOnion.DynamicArgumentTuple, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs index 74cf52b60..25bf3b16b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace MyApplication1 { using global::System; @@ -11,7 +10,7 @@ namespace MyApplication1 using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService { @@ -27,22 +26,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.CanGreetAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "CanGreetAsync", serializerProvider); } } - + readonly ClientCore core; - + public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new GreeterServiceClient(options, core); - + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); public global::MagicOnion.UnaryResult PingAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs index 573953e7f..8c6701050 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs @@ -3,7 +3,6 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - namespace TempProject { using global::System; @@ -11,7 +10,7 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - + [global::MagicOnion.Ignore] public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { @@ -23,22 +22,22 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); } } - + readonly ClientCore core; - + public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); } - + private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) { this.core = core; } - + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyServiceClient(options, core); - + public global::MagicOnion.UnaryResult A() => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } From ea84208da38f5f830b2eb9c90fd9ee9d4e75a04b Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 15:12:38 +0900 Subject: [PATCH 35/66] Remove System.CodeDom reference --- .../MagicOnion.Client.SourceGenerator.Unity.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj index 5507cdce6..afdaca30b 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -31,7 +31,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - From 2fcf268fa189f2433f136eab57c24ee2a66bbf6c Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 16:00:23 +0900 Subject: [PATCH 36/66] WIP --- .../MagicOnionServiceInfoExtensions.cs | 10 +- .../CodeGen/MagicOnionInitializerGenerator.cs | 18 +- .../MessagePackFormatterResolverGenerator.cs | 2 +- .../StaticMagicOnionClientGenerator.cs | 90 +++--- .../StaticStreamingHubClientGenerator.cs | 283 +++++++++--------- .../MagicOnionClientGenerator.cs | 4 +- .../MagicOnionClientSourceGenerator.cs | 2 +- .../GenerateTest.cs | 23 ++ ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 105 +++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 141 ++++----- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 97 +++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyHubClient.g.cs | 97 +++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 105 +++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 97 +++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 105 +++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 117 ++++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 97 +++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyHubClient.g.cs | 97 +++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 117 ++++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 159 +++++----- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 117 ++++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 117 ++++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 131 ++++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../Return/0003_TempProject_MyHubClient.g.cs | 117 ++++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 159 +++++----- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 117 ++++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 117 ++++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 131 ++++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 129 ++++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 71 +++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 81 ++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 63 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 71 +++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 63 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 81 ++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 63 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 63 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 71 +++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...003_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0004_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 71 +++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 14 +- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 14 +- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 14 +- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 14 +- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 71 +++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../Complex/0003_TempProject_MyHubClient.g.cs | 187 ++++++------ ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 111 +++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 111 +++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 111 +++---- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 14 +- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 14 +- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 103 ++++--- ...1_MyApplication1_GreeterServiceClient.g.cs | 71 +++-- ...ation1_MagicOnionInitializer_Resolver.g.cs | 2 +- ..._MyApplication1_MagicOnionInitializer.g.cs | 16 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ++ ...on1_Net_Remoting_GreeterServiceClient.g.cs | 58 ++++ ...moting_MagicOnionInitializer_Resolver.g.cs | 78 +++++ ...moting_MagicOnionInitializer_Resolver.g.cs | 78 +++++ ...n1_Net_Remoting_MagicOnionInitializer.g.cs | 85 ++++++ .../0003_Remoting_MagicOnionInitializer.g.cs | 87 ++++++ ...espace_MagicOnionInitializer_Resolver.g.cs | 2 +- ...006_MyNamespace_MagicOnionInitializer.g.cs | 16 +- .../0007_MyNamespace_MyServiceClient.g.cs | 55 ++-- ...1_MyApplication1_GreeterServiceClient.g.cs | 71 +++-- ...ation1_MagicOnionInitializer_Resolver.g.cs | 2 +- ..._MyApplication1_MagicOnionInitializer.g.cs | 16 +- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyServiceClient.g.cs | 55 ++-- ...roject_MagicOnionInitializer_Resolver.g.cs | 2 +- ...002_TempProject_MagicOnionInitializer.g.cs | 16 +- .../0003_TempProject_MyHubClient.g.cs | 111 +++---- .../ClientFilterTest.cs | 4 +- .../DynamicArgumentTupleTest.cs | 5 +- .../MagicOnionClientGeneratorOptions.json | 5 - .../MagicOnionGeneratedClientInitializer.cs | 2 +- .../SerializerStreamingHubTest.cs | 6 +- .../SerializerUnaryTest.cs | 5 +- .../StreamingHubTest.cs | 19 +- .../StreamingServiceTest.cs | 9 +- .../UnaryServiceTest.cs | 9 +- 260 files changed, 4881 insertions(+), 4229 deletions(-) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0001_MyApplication1_Net_Remoting_GreeterServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_Remoting_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_Remoting_MagicOnionInitializer.g.cs delete mode 100644 tests/MagicOnion.Integration.Tests/MagicOnionClientGeneratorOptions.json diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs index 88dfa1bb8..150dc27cb 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs @@ -1,4 +1,3 @@ -using System.Text.RegularExpressions; using MagicOnion.Client.SourceGenerator.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator.CodeGen.Extensions; @@ -10,8 +9,13 @@ public static class MagicOnionServiceInfoExtensions // - IImportantService --> ImportantServiceClient // - I0123Service --> I0123ServiceClient public static string GetClientName(this IMagicOnionServiceInfo serviceInfo) - => (Regex.IsMatch(serviceInfo.ServiceType.Name, "I[^a-z0-9]") ? serviceInfo.ServiceType.Name.Substring(1) : serviceInfo.ServiceType.Name) + "Client"; + => ( + serviceInfo.ServiceType.Name.Length > 1 && serviceInfo.ServiceType.Name.StartsWith("I") && !Char.IsNumber(serviceInfo.ServiceType.Name[1]) + ? serviceInfo.ServiceType.Name.Substring(1) + : serviceInfo.ServiceType.Name + ) + "Client"; + // - Foo.Bar.BazClient --> Foo_Bar_BazClient public static string GetClientFullName(this IMagicOnionServiceInfo serviceInfo) - => (serviceInfo.ServiceType.Namespace != null ? serviceInfo.ServiceType.Namespace + "." : "") + serviceInfo.GetClientName(); + => ((serviceInfo.ServiceType.Namespace != null ? serviceInfo.ServiceType.Namespace + "." : "") + serviceInfo.GetClientName()).Replace(".", "_"); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs index 99a8f16a0..f40609bdc 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs @@ -33,13 +33,11 @@ partial class PreserveAttribute : global::System.Attribute {} partial class {{typeName}} { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static {{typeName}} Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; """); if (!options.DisableAutoRegister) @@ -50,12 +48,12 @@ partial class {{typeName}} #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); """); } writer.WriteLine($$""" - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -96,7 +94,7 @@ static MagicOnionClientFactoryCache() writer.WriteLine($$""" if (typeof(T) == typeof({{serviceInfo.ServiceType.FullName}})) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate<{{serviceInfo.ServiceType.FullName}}>)((x, y) => new {{serviceInfo.GetClientFullName()}}(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate<{{serviceInfo.ServiceType.FullName}}>)((x, y) => new MagicOnionGeneratedClient.{{serviceInfo.GetClientFullName()}}(x, y))); } """); } @@ -120,7 +118,7 @@ static StreamingHubClientFactoryCache() writer.WriteLine($$""" if (typeof(TStreamingHub) == typeof({{hubInfo.ServiceType.FullName}}) && typeof(TReceiver) == typeof({{hubInfo.Receiver.ReceiverType.FullName}})) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate<{{hubInfo.ServiceType.FullName}}, {{hubInfo.Receiver.ReceiverType.FullName}}>)((a, _, b, c, d, e) => new {{hubInfo.GetClientFullName()}}(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate<{{hubInfo.ServiceType.FullName}}, {{hubInfo.Receiver.ReceiverType.FullName}}>)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.{{hubInfo.GetClientFullName()}}(a, b, c, d, e))); } """); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs index 66ef3b3d7..dcfb562ef 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs @@ -39,7 +39,7 @@ namespace {{generationContext.Namespace}} partial class {{generationContext.InitializerPartialTypeName}} { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; """); EmitResolver(ctx); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs index 9d00f4426..fd68cacd2 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs @@ -20,25 +20,25 @@ public ServiceClientBuildContext(MagicOnionServiceInfo service, TextWriter textW public TextWriter TextWriter { get; } } - public static string Build(IEnumerable services) + public static string Build(GenerationContext generationContext, IEnumerable services) { var textWriter = new StringWriter(); - EmitHeader(textWriter); + EmitHeader(generationContext, textWriter); foreach (var serviceInfo in services) { var buildContext = new ServiceClientBuildContext(serviceInfo, textWriter); - EmitPreamble(buildContext); - EmitServiceClientClass(buildContext); - EmitPostscript(buildContext); + EmitPreamble(generationContext, buildContext); + EmitServiceClientClass(generationContext, buildContext); + EmitPostscript(generationContext, buildContext); } return textWriter.ToString(); } - static void EmitHeader(TextWriter textWriter) + static void EmitHeader(GenerationContext generationContext, TextWriter textWriter) { textWriter.WriteLine(""" // @@ -49,38 +49,54 @@ static void EmitHeader(TextWriter textWriter) """); } - static void EmitPreamble(ServiceClientBuildContext ctx) + static void EmitPreamble(GenerationContext generationContext, ServiceClientBuildContext ctx) { - ctx.TextWriter.WriteLine($$""" - namespace {{ctx.Service.ServiceType.Namespace}} + if (!string.IsNullOrWhiteSpace(generationContext.Namespace)) + { + ctx.TextWriter.WriteLine($$""" + namespace {{generationContext.Namespace}} { + """); + } + ctx.TextWriter.WriteLine($$""" using global::System; using global::Grpc.Core; using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; + partial class {{generationContext.InitializerPartialTypeName}} + { + static partial class MagicOnionGeneratedClient + { """); } - static void EmitPostscript(ServiceClientBuildContext ctx) + static void EmitPostscript(GenerationContext generationContext, ServiceClientBuildContext ctx) { ctx.TextWriter.WriteLine(""" + } + } + """); + + if (!string.IsNullOrWhiteSpace(generationContext.Namespace)) + { + ctx.TextWriter.WriteLine(""" } """); - ctx.TextWriter.WriteLine(); + } } - static void EmitServiceClientClass(ServiceClientBuildContext ctx) + static void EmitServiceClientClass(GenerationContext generationContext, ServiceClientBuildContext ctx) { // [Ignore] // public class {ServiceName}Client : MagicOnionClientBase<{ServiceName}>, {ServiceName} // { // ctx.TextWriter.WriteLine($$""" - [global::MagicOnion.Ignore] - public class {{ctx.Service.GetClientName()}} : global::MagicOnion.Client.MagicOnionClientBase<{{ctx.Service.ServiceType.FullName}}>, {{ctx.Service.ServiceType.FullName}} - { + [global::MagicOnion.Ignore] + public class {{ctx.Service.GetClientFullName()}} : global::MagicOnion.Client.MagicOnionClientBase<{{ctx.Service.ServiceType.FullName}}>, {{ctx.Service.ServiceType.FullName}} + { """); // class ClientCore { ... } EmitClientCore(ctx); @@ -95,7 +111,7 @@ public class {{ctx.Service.GetClientName()}} : global::MagicOnion.Client.MagicOn EmitServiceMethods(ctx); ctx.TextWriter.WriteLine(""" - } + } """); // } } @@ -103,8 +119,8 @@ public class {{ctx.Service.GetClientName()}} : global::MagicOnion.Client.MagicOn static void EmitClone(ServiceClientBuildContext ctx) { ctx.TextWriter.WriteLine($""" - protected override global::MagicOnion.Client.MagicOnionClientBase<{ctx.Service.ServiceType.Name}> Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new {ctx.Service.GetClientName()}(options, core); + protected override global::MagicOnion.Client.MagicOnionClientBase<{ctx.Service.ServiceType.Name}> Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new {ctx.Service.GetClientFullName()}(options, core); """); ctx.TextWriter.WriteLine(); } @@ -112,15 +128,15 @@ static void EmitClone(ServiceClientBuildContext ctx) static void EmitConstructor(ServiceClientBuildContext ctx) { ctx.TextWriter.WriteLine($$""" - public {{ctx.Service.GetClientName()}}(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } + public {{ctx.Service.GetClientFullName()}}(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } - private {{ctx.Service.GetClientName()}}(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } + private {{ctx.Service.GetClientFullName()}}(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } """); } @@ -129,7 +145,7 @@ static void EmitFields(ServiceClientBuildContext ctx) { // private readonly ClientCore core; ctx.TextWriter.WriteLine(""" - readonly ClientCore core; + readonly ClientCore core; """); } @@ -167,8 +183,8 @@ _ when (method.MethodType != MethodType.Unary && method.MethodType != MethodType var hasNonGenericUnaryResult = method.MethodReturnType == MagicOnionTypeInfo.KnownTypes.MagicOnion_UnaryResult; ctx.TextWriter.WriteLine($""" - public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) - => this.core.{method.MethodName}.Invoke{method.MethodType}{(hasNonGenericUnaryResult ? "NonGeneric" : "")}(this, "{method.Path}"{invokeRequestParameters}); + public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) + => this.core.{method.MethodName}.Invoke{method.MethodType}{(hasNonGenericUnaryResult ? "NonGeneric" : "")}(this, "{method.Path}"{invokeRequestParameters}); """); } } @@ -190,22 +206,22 @@ static void EmitClientCore(ServiceClientBuildContext ctx) // class ClientCore { ctx.TextWriter.WriteLine(""" - class ClientCore - { + class ClientCore + { """); // public RawMethodInvoker MethodName; foreach (var method in ctx.Service.Methods) { ctx.TextWriter.WriteLine($$""" - public global::MagicOnion.Client.Internal.RawMethodInvoker<{{method.RequestType.FullName}}, {{method.ResponseType.FullName}}> {{method.MethodName}}; + public global::MagicOnion.Client.Internal.RawMethodInvoker<{{method.RequestType.FullName}}, {{method.ResponseType.FullName}}> {{method.MethodName}}; """); } // public ClientCore(IMagicOnionSerializerProvider serializerProvider) { ctx.TextWriter.WriteLine(""" - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { """); // MethodName = RawMethodInvoker.Create_XXXType_XXXType(MethodType, ServiceName, MethodName, serializerProvider); @@ -213,12 +229,12 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider { var createMethodVariant = $"{(method.RequestType.IsValueType ? "Value" : "Ref")}Type_{(method.ResponseType.IsValueType ? "Value" : "Ref")}Type"; ctx.TextWriter.WriteLine($$""" - this.{{method.MethodName}} = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_{{createMethodVariant}}<{{method.RequestType.FullName}}, {{method.ResponseType.FullName}}>(global::Grpc.Core.MethodType.{{method.MethodType}}, "{{method.ServiceName}}", "{{method.MethodName}}", serializerProvider); + this.{{method.MethodName}} = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_{{createMethodVariant}}<{{method.RequestType.FullName}}, {{method.ResponseType.FullName}}>(global::Grpc.Core.MethodType.{{method.MethodType}}, "{{method.ServiceName}}", "{{method.MethodName}}", serializerProvider); """); } ctx.TextWriter.WriteLine(""" - } - } + } + } """); // } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs index 26b463407..62c7437fa 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs @@ -9,7 +9,7 @@ public class StaticStreamingHubClientGenerator { class StreamingHubClientBuildContext { - public StreamingHubClientBuildContext(MagicOnionStreamingHubInfo hub, IndentedTextWriter textWriter) + public StreamingHubClientBuildContext(MagicOnionStreamingHubInfo hub, TextWriter textWriter) { Hub = hub; TextWriter = textWriter; @@ -17,126 +17,142 @@ public StreamingHubClientBuildContext(MagicOnionStreamingHubInfo hub, IndentedTe public MagicOnionStreamingHubInfo Hub { get; } - public IndentedTextWriter TextWriter { get; } + public TextWriter TextWriter { get; } } - public static string Build(IEnumerable hubs) + public static string Build(GenerationContext generationContext, IEnumerable hubs) { var baseWriter = new StringWriter(); var textWriter = new IndentedTextWriter(baseWriter); - EmitHeader(textWriter); + EmitHeader(generationContext, textWriter); foreach (var hubInfo in hubs) { var buildContext = new StreamingHubClientBuildContext(hubInfo, textWriter); - EmitPreamble(buildContext); - EmitHubClientClass(buildContext); - EmitPostscript(buildContext); + EmitPreamble(generationContext, buildContext); + EmitHubClientClass(generationContext, buildContext); + EmitPostscript(generationContext, buildContext); } return baseWriter.ToString(); } - static void EmitHeader(IndentedTextWriter textWriter) + static void EmitHeader(GenerationContext generationContext, IndentedTextWriter textWriter) { textWriter.WriteLines(""" - // - #pragma warning disable CS0618 // 'member' is obsolete: 'text' - #pragma warning disable CS0612 // 'member' is obsolete - #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used - #pragma warning disable CS8019 // Unnecessary using directive. - """); - textWriter.WriteLine(); + // + #pragma warning disable CS0618 // 'member' is obsolete: 'text' + #pragma warning disable CS0612 // 'member' is obsolete + #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used + #pragma warning disable CS8019 // Unnecessary using directive. + + """); } - static void EmitPreamble(StreamingHubClientBuildContext ctx) + static void EmitPreamble(GenerationContext generationContext, StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLines($$""" - namespace {{ctx.Hub.ServiceType.Namespace}} + if (!string.IsNullOrWhiteSpace(generationContext.Namespace)) { - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - """); - ctx.TextWriter.Indent++; - ctx.TextWriter.WriteLine(); - } + ctx.TextWriter.WriteLine($$""" + namespace {{generationContext.Namespace}} + { + """); + } + ctx.TextWriter.WriteLine($$""" + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; - static void EmitPostscript(StreamingHubClientBuildContext ctx) - { - ctx.TextWriter.Indent--; - ctx.TextWriter.WriteLine("}"); - ctx.TextWriter.WriteLine(); + partial class {{generationContext.InitializerPartialTypeName}} + { + static partial class MagicOnionGeneratedClient + { + """); } - static void EmitHubClientClass(StreamingHubClientBuildContext ctx) + static void EmitPostscript(GenerationContext generationContext, StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLines($$""" - [global::MagicOnion.Ignore] - public class {{ctx.Hub.GetClientName()}} : global::MagicOnion.Client.StreamingHubClientBase<{{ctx.Hub.ServiceType.FullName}}, {{ctx.Hub.Receiver.ReceiverType.FullName}}>, {{ctx.Hub.ServiceType.FullName}} - { - """); - using (ctx.TextWriter.BeginIndent()) + ctx.TextWriter.WriteLine(""" + } + } + """); + + if (!string.IsNullOrWhiteSpace(generationContext.Namespace)) { - EmitProperties(ctx); - EmitConstructor(ctx); - EmitHubMethods(ctx, isFireAndForget: false); - EmitFireAndForget(ctx); - EmitOnBroadcastEvent(ctx); - EmitOnResponseEvent(ctx); + ctx.TextWriter.WriteLine(""" + } + """); } - ctx.TextWriter.WriteLine("}"); + } + + static void EmitHubClientClass(GenerationContext generationContext, StreamingHubClientBuildContext ctx) + { + ctx.TextWriter.WriteLine($$""" + [global::MagicOnion.Ignore] + public class {{ctx.Hub.GetClientFullName()}} : global::MagicOnion.Client.StreamingHubClientBase<{{ctx.Hub.ServiceType.FullName}}, {{ctx.Hub.Receiver.ReceiverType.FullName}}>, {{ctx.Hub.ServiceType.FullName}} + { + """); + EmitProperties(ctx); + EmitConstructor(ctx); + EmitHubMethods(ctx, isFireAndForget: false); + EmitFireAndForget(ctx); + EmitOnBroadcastEvent(ctx); + EmitOnResponseEvent(ctx); + ctx.TextWriter.WriteLine(""" + } + """); // } } static void EmitProperties(StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLine("protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; }"); - ctx.TextWriter.WriteLine(); + ctx.TextWriter.WriteLine(""" + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + """); } static void EmitConstructor(StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLines($$""" - public {{ctx.Hub.GetClientName()}}(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "{{ctx.Hub.ServiceType.Name}}", "Connect", marshaller, marshaller); - } - """); + ctx.TextWriter.WriteLine($$""" + public {{ctx.Hub.GetClientFullName()}}(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "{{ctx.Hub.ServiceType.Name}}", "Connect", marshaller, marshaller); + } + """); ctx.TextWriter.WriteLine(); } static void EmitFireAndForget(StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLines($$""" - public {{ctx.Hub.ServiceType.FullName}} FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : {{ctx.Hub.ServiceType.FullName}} - { - readonly {{ctx.Hub.GetClientName()}} parent; + ctx.TextWriter.WriteLine($$""" + public {{ctx.Hub.ServiceType.FullName}} FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : {{ctx.Hub.ServiceType.FullName}} + { + readonly {{ctx.Hub.GetClientFullName()}} parent; - public FireAndForgetClient({{ctx.Hub.GetClientName()}} parent) - => this.parent = parent; + public FireAndForgetClient({{ctx.Hub.GetClientFullName()}} parent) + => this.parent = parent; - public {{ctx.Hub.ServiceType.FullName}} FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + public {{ctx.Hub.ServiceType.FullName}} FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - """); - using (ctx.TextWriter.BeginIndent()) - { - EmitHubMethods(ctx, isFireAndForget: true); - } - ctx.TextWriter.WriteLine("}"); - ctx.TextWriter.WriteLine(); + """); + EmitHubMethods(ctx, isFireAndForget: true); + ctx.TextWriter.WriteLine(""" + } + + """); } static void EmitHubMethods(StreamingHubClientBuildContext ctx, bool isFireAndForget) @@ -161,29 +177,32 @@ static void EmitHubMethods(StreamingHubClientBuildContext ctx, bool isFireAndFor _ => $", {method.Parameters.ToNewDynamicArgumentTuple()}", }; + if (isFireAndForget) ctx.TextWriter.Write(" "); + ctx.TextWriter.WriteLine($""" + public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) + """); + + if (isFireAndForget) ctx.TextWriter.Write(" "); if (method.MethodReturnType == MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_ValueTask) { // ValueTask - ctx.TextWriter.WriteLines($""" - public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) - => new global::System.Threading.Tasks.ValueTask({(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters})); - """); + ctx.TextWriter.WriteLine($""" + => new global::System.Threading.Tasks.ValueTask({(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters})); + """); } else if (method.MethodReturnType.HasGenericArguments && method.MethodReturnType.GetGenericTypeDefinition() == MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_ValueTask) { // ValueTask - ctx.TextWriter.WriteLines($""" - public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) - => new global::System.Threading.Tasks.ValueTask<{method.ResponseType.FullName}>({(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters})); - """); + ctx.TextWriter.WriteLine($""" + => new global::System.Threading.Tasks.ValueTask<{method.ResponseType.FullName}>({(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters})); + """); } else { // Task, Task - ctx.TextWriter.WriteLines($""" - public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) - => {(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters}); - """); + ctx.TextWriter.WriteLine($""" + => {(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters}); + """); } } @@ -192,61 +211,57 @@ static void EmitHubMethods(StreamingHubClientBuildContext ctx, bool isFireAndFor static void EmitOnBroadcastEvent(StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLine("protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data)"); - ctx.TextWriter.WriteLine("{"); - using (ctx.TextWriter.BeginIndent()) + ctx.TextWriter.WriteLine(""" + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + """); + foreach (var method in ctx.Hub.Receiver.Methods) { - ctx.TextWriter.WriteLine("switch (methodId)"); - ctx.TextWriter.WriteLine("{"); - using (ctx.TextWriter.BeginIndent()) + var methodArgs = method.Parameters.Count switch { - foreach (var method in ctx.Hub.Receiver.Methods) - { - var methodArgs = method.Parameters.Count switch - { - 0 => "", - 1 => "value", - _ => string.Join(", ", Enumerable.Range(1, method.Parameters.Count).Select(x => $"value.Item{x}")) - }; + 0 => "", + 1 => "value", + _ => string.Join(", ", Enumerable.Range(1, method.Parameters.Count).Select(x => $"value.Item{x}")) + }; - ctx.TextWriter.WriteLines($$""" - case {{method.HubId}}: // {{method.MethodReturnType.ToDisplayName()}} {{method.MethodName}}({{method.Parameters.ToMethodSignaturize()}}) - { - var value = base.Deserialize<{{method.RequestType.FullName}}>(data); - receiver.{{method.MethodName}}({{methodArgs}}); - } - break; - """); - } - } - ctx.TextWriter.WriteLine("}"); + ctx.TextWriter.WriteLine($$""" + case {{method.HubId}}: // {{method.MethodReturnType.ToDisplayName()}} {{method.MethodName}}({{method.Parameters.ToMethodSignaturize()}}) + { + var value = base.Deserialize<{{method.RequestType.FullName}}>(data); + receiver.{{method.MethodName}}({{methodArgs}}); + } + break; + """); } - ctx.TextWriter.WriteLine("}"); - ctx.TextWriter.WriteLine(); + ctx.TextWriter.WriteLine(""" + } + } + + """); } static void EmitOnResponseEvent(StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLine("protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data)"); - ctx.TextWriter.WriteLine("{"); - using (ctx.TextWriter.BeginIndent()) + ctx.TextWriter.WriteLine(""" + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + """); + foreach (var method in ctx.Hub.Methods) { - ctx.TextWriter.WriteLine("switch (methodId)"); - ctx.TextWriter.WriteLine("{"); - using (ctx.TextWriter.BeginIndent()) - { - foreach (var method in ctx.Hub.Methods) - { - ctx.TextWriter.WriteLines($$""" - case {{method.HubId}}: // {{method.MethodReturnType.ToDisplayName()}} {{method.MethodName}}({{method.Parameters.ToMethodSignaturize()}}) - base.SetResultForResponse<{{method.ResponseType.FullName}}>(taskCompletionSource, data); - break; - """); - } - } - ctx.TextWriter.WriteLine("}"); + ctx.TextWriter.WriteLine($$""" + case {{method.HubId}}: // {{method.MethodReturnType.ToDisplayName()}} {{method.MethodName}}({{method.Parameters.ToMethodSignaturize()}}) + base.SetResultForResponse<{{method.ResponseType.FullName}}>(taskCompletionSource, data); + break; + """); } - ctx.TextWriter.WriteLine("}"); - ctx.TextWriter.WriteLine(); + ctx.TextWriter.WriteLine(""" + } + } + + """); } } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs index 72d4a0cb6..b6ab6b473 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs @@ -58,13 +58,13 @@ public static class MagicOnionClientGenerator foreach (var service in serviceCollection.Services) { - var x = StaticMagicOnionClientGenerator.Build(new[] { service }); + var x = StaticMagicOnionClientGenerator.Build(context, new[] { service }); outputs.Add((GeneratePathFromNamespaceAndTypeName(service.ServiceType.Namespace, service.GetClientName()), x)); } foreach (var hub in serviceCollection.Hubs) { - var x = StaticStreamingHubClientGenerator.Build(new [] { hub }); + var x = StaticStreamingHubClientGenerator.Build(context, new [] { hub }); outputs.Add((GeneratePathFromNamespaceAndTypeName(hub.ServiceType.Namespace, hub.GetClientName()), x)); } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 6bd1a08fb..b4d84c322 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -50,7 +50,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) var initializerPartialTypeNamespace = initializerClassSymbol.ContainingNamespace.IsGlobalNamespace ? null - : initializerClassSymbol.ContainingNamespace.Name; + : initializerClassSymbol.ContainingNamespace.ToDisplayString(); var initializerPartialTypeName = initializerClassSymbol.Name; var generationContext = new GenerationContext(initializerPartialTypeNamespace, initializerPartialTypeName, sourceProductionContext); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs index dd730a56a..d316d29ce 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs @@ -72,6 +72,29 @@ partial class MagicOnionInitializer {} await MagicOnionSourceGeneratorVerifier.RunAsync(source); } + [Fact] + public async Task Generate_Namespace() + { + var source = """ + using MagicOnion; + using MagicOnion.Client; + + namespace MyApplication1.Net.Remoting; + + public interface IGreeterService : IService + { + UnaryResult HelloAsync(string name, int age); + UnaryResult PingAsync(); + UnaryResult CanGreetAsync(); + } + + [MagicOnionClientGeneration(typeof(IGreeterService))] + partial class MagicOnionInitializer {} + """; + + await MagicOnionSourceGeneratorVerifier.RunAsync(source); + } + [Fact] public async Task ImplicitUsings_PropertyGroup_Enable() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 84231fe0d..ddbcd27ae 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs index 06289231b..73d7f6865 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetEnumAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetEnumAsync(global::System.Nullable a) + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult GetEnumAsync(global::System.Nullable a) - => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 6436a4796..3ee70a438 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs index fb95094b4..716ddeb35 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker GetEnumAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetEnumAsync(global::TempProject.MyEnum a) + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult GetEnumAsync(global::TempProject.MyEnum a) - => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index e8f13eb93..30d2aa060 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs index 6c753abac..e2e327613 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetEnumAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetEnumAsync(global::System.Nullable a) + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult GetEnumAsync(global::System.Nullable a) - => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", a); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 6436a4796..3ee70a438 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs index 699033b27..3e0cd5118 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker GetEnumAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetEnumAsync() + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult GetEnumAsync() - => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index e8f13eb93..30d2aa060 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs index 7102af582..6a45bfb98 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker> GetEnumAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> GetEnumAsync() + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult> GetEnumAsync() - => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8fb1d4a66..563c6e0d8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0003_TempProject_MyHubClient.g.cs index d64f5e6c1..01d8b5837 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0003_TempProject_MyHubClient.g.cs @@ -11,64 +11,69 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1005848884: // Void A(global::TempProject.MyGenericObject a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.A(value); + case -1005848884: // Void A(global::TempProject.MyGenericObject a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; + case -955516027: // Void B(global::TempProject.MyGenericObject b) + { + var value = base.Deserialize>(data); + receiver.B(value); + } + break; } - break; - case -955516027: // Void B(global::TempProject.MyGenericObject b) + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.B(value); } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index dbf14c6ca..0d16a45ab 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index 8599620a6..be91c6e71 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -11,82 +11,87 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1005848884: // Void A(global::System.String[] a) - { - var value = base.Deserialize(data); - receiver.A(value); - } - break; - case -955516027: // Void B(global::System.Int32[] a) - { - var value = base.Deserialize(data); - receiver.B(value); - } - break; - case -972293646: // Void C(global::System.Int32[] a) - { - var value = base.Deserialize(data); - receiver.C(value); - } - break; - case -1056181741: // Void D(global::System.Single[] a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize(data); - receiver.D(value); + case -1005848884: // Void A(global::System.String[] a) + { + var value = base.Deserialize(data); + receiver.A(value); + } + break; + case -955516027: // Void B(global::System.Int32[] a) + { + var value = base.Deserialize(data); + receiver.B(value); + } + break; + case -972293646: // Void C(global::System.Int32[] a) + { + var value = base.Deserialize(data); + receiver.C(value); + } + break; + case -1056181741: // Void D(global::System.Single[] a) + { + var value = base.Deserialize(data); + receiver.D(value); + } + break; + case -1072959360: // Void E(global::System.Boolean[] a) + { + var value = base.Deserialize(data); + receiver.E(value); + } + break; } - break; - case -1072959360: // Void E(global::System.Boolean[] a) + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize(data); - receiver.E(value); } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c306c1595..4a8cdd678 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs index 5cde72b7e..1ae5aa565 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -11,58 +11,63 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1005848884: // Void A(global::TempProject.MyResponse[] a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize(data); - receiver.A(value); + case -1005848884: // Void A(global::TempProject.MyResponse[] a) + { + var value = base.Deserialize(data); + receiver.A(value); + } + break; } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index ac8cfb352..55eaace57 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs index a57fe584a..fe2616d09 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs @@ -11,58 +11,63 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1005848884: // Void A(global::TempProject.MyGenericObject a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.A(value); + case -1005848884: // Void A(global::TempProject.MyGenericObject a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8ac488062..c184bcbe5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index a632479e3..7059bdada 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -11,64 +11,69 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1005848884: // Void A(global::System.Collections.Generic.List a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.A(value); + case -1005848884: // Void A(global::System.Collections.Generic.List a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; + case -955516027: // Void B(global::System.Collections.Generic.List b) + { + var value = base.Deserialize>(data); + receiver.B(value); + } + break; } - break; - case -955516027: // Void B(global::System.Collections.Generic.List b) + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.B(value); } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cc5556914..5ce12962f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs index 3f99d3cde..5e8b6aa5d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -11,58 +11,63 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1005848884: // Void A(global::System.Collections.Generic.List a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.A(value); + case -1005848884: // Void A(global::System.Collections.Generic.List a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4b5eb605e..4e1919c85 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs index bda0b687d..8aacb4324 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs @@ -11,64 +11,69 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1005848884: // Void A(global::TempProject.MyGenericObject a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.A(value); + case -1005848884: // Void A(global::TempProject.MyGenericObject a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; + case -955516027: // Void B(global::TempProject.MyGenericObject b) + { + var value = base.Deserialize>(data); + receiver.B(value); + } + break; } - break; - case -955516027: // Void B(global::TempProject.MyGenericObject b) + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.B(value); } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5a58eef11..8c11aee07 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs index 4894f4a53..54c0f38d6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs @@ -11,70 +11,75 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1005848884: // Void A(global::TempProject.MyGenericObject> a) - { - var value = base.Deserialize>>(data); - receiver.A(value); - } - break; - case -955516027: // Void B(global::TempProject.MyGenericObject>> b) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>>>(data); - receiver.B(value); + case -1005848884: // Void A(global::TempProject.MyGenericObject> a) + { + var value = base.Deserialize>>(data); + receiver.A(value); + } + break; + case -955516027: // Void B(global::TempProject.MyGenericObject>> b) + { + var value = base.Deserialize>>>(data); + receiver.B(value); + } + break; + case -972293646: // Void C(global::TempProject.MyGenericObject>> c) + { + var value = base.Deserialize>>>(data); + receiver.C(value); + } + break; } - break; - case -972293646: // Void C(global::TempProject.MyGenericObject>> c) + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>>>(data); - receiver.C(value); } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cece63905..4bac6483d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0003_TempProject_MyHubClient.g.cs index e795b7c4a..bc96a8e3f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0003_TempProject_MyHubClient.g.cs @@ -11,58 +11,63 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1005848884: // Void A(global::TempProject.MyGenericObject a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.A(value); + case -1005848884: // Void A(global::TempProject.MyGenericObject a) + { + var value = base.Deserialize>(data); + receiver.A(value); + } + break; } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 7d5c94552..29106145e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0004_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0004_TempProject_MyHubClient.g.cs index f7a707aeb..428ec682e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0004_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0004_TempProject_MyHubClient.g.cs @@ -11,58 +11,63 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1005848884: // Void A(global::TempProject.MyGenericObject> a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>>(data); - receiver.A(value); + case -1005848884: // Void A(global::TempProject.MyGenericObject> a) + { + var value = base.Deserialize>>(data); + receiver.A(value); + } + break; } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8fb1d4a66..563c6e0d8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0003_TempProject_MyHubClient.g.cs index b783d9355..e143d57ea 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0003_TempProject_MyHubClient.g.cs @@ -11,66 +11,71 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1005848884, a); - public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-955516027, a); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1005848884, a); - public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-955516027, a); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-955516027, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-955516027, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyGenericObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -955516027: // Task B(global::TempProject.MyGenericObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::TempProject.MyGenericObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -955516027: // Task B(global::TempProject.MyGenericObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index dbf14c6ca..0d16a45ab 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index 3079ce057..0059eac65 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -11,87 +11,92 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.String[] arg0) - => base.WriteMessageWithResponseAsync(1774317884, arg0); - public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Int32[] arg0) - => base.WriteMessageWithResponseAsync(-400881550, arg0); - public global::System.Threading.Tasks.Task GetInt32ValuesAsync(global::System.Int32[] arg0) - => base.WriteMessageWithResponseAsync(309063297, arg0); - public global::System.Threading.Tasks.Task GetSingleValuesAsync(global::System.Single[] arg0) - => base.WriteMessageWithResponseAsync(702446639, arg0); - public global::System.Threading.Tasks.Task GetBooleanValuesAsync(global::System.Boolean[] arg0) - => base.WriteMessageWithResponseAsync(2082077357, arg0); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.String[] arg0) - => parent.WriteMessageFireAndForgetAsync(1774317884, arg0); - public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Int32[] arg0) - => parent.WriteMessageFireAndForgetAsync(-400881550, arg0); - public global::System.Threading.Tasks.Task GetInt32ValuesAsync(global::System.Int32[] arg0) - => parent.WriteMessageFireAndForgetAsync(309063297, arg0); - public global::System.Threading.Tasks.Task GetSingleValuesAsync(global::System.Single[] arg0) - => parent.WriteMessageFireAndForgetAsync(702446639, arg0); - public global::System.Threading.Tasks.Task GetBooleanValuesAsync(global::System.Boolean[] arg0) - => parent.WriteMessageFireAndForgetAsync(2082077357, arg0); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.String[] arg0) + => base.WriteMessageWithResponseAsync(1774317884, arg0); + public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Int32[] arg0) + => base.WriteMessageWithResponseAsync(-400881550, arg0); + public global::System.Threading.Tasks.Task GetInt32ValuesAsync(global::System.Int32[] arg0) + => base.WriteMessageWithResponseAsync(309063297, arg0); + public global::System.Threading.Tasks.Task GetSingleValuesAsync(global::System.Single[] arg0) + => base.WriteMessageWithResponseAsync(702446639, arg0); + public global::System.Threading.Tasks.Task GetBooleanValuesAsync(global::System.Boolean[] arg0) + => base.WriteMessageWithResponseAsync(2082077357, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.String[] arg0) + => parent.WriteMessageFireAndForgetAsync(1774317884, arg0); + public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Int32[] arg0) + => parent.WriteMessageFireAndForgetAsync(-400881550, arg0); + public global::System.Threading.Tasks.Task GetInt32ValuesAsync(global::System.Int32[] arg0) + => parent.WriteMessageFireAndForgetAsync(309063297, arg0); + public global::System.Threading.Tasks.Task GetSingleValuesAsync(global::System.Single[] arg0) + => parent.WriteMessageFireAndForgetAsync(702446639, arg0); + public global::System.Threading.Tasks.Task GetBooleanValuesAsync(global::System.Boolean[] arg0) + => parent.WriteMessageFireAndForgetAsync(2082077357, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case 1774317884: // Task GetStringValuesAsync(global::System.String[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -400881550: // Task GetIntValuesAsync(global::System.Int32[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + case 309063297: // Task GetInt32ValuesAsync(global::System.Int32[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + case 702446639: // Task GetSingleValuesAsync(global::System.Single[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + case 2082077357: // Task GetBooleanValuesAsync(global::System.Boolean[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case 1774317884: // Task GetStringValuesAsync(global::System.String[] arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -400881550: // Task GetIntValuesAsync(global::System.Int32[] arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 309063297: // Task GetInt32ValuesAsync(global::System.Int32[] arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 702446639: // Task GetSingleValuesAsync(global::System.Single[] arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 2082077357: // Task GetBooleanValuesAsync(global::System.Boolean[] arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c306c1595..4a8cdd678 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs index 3ca2a66ec..c2f1316df 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyResponse[] arg0) - => base.WriteMessageWithResponseAsync(-209315513, arg0); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyResponse[] arg0) - => parent.WriteMessageFireAndForgetAsync(-209315513, arg0); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyResponse[] arg0) + => base.WriteMessageWithResponseAsync(-209315513, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyResponse[] arg0) + => parent.WriteMessageFireAndForgetAsync(-209315513, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task GetValuesAsync(global::TempProject.MyResponse[] arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -209315513: // Task GetValuesAsync(global::TempProject.MyResponse[] arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8ac488062..c184bcbe5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index 250c36d7d..5932cee1d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -11,66 +11,71 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.Collections.Generic.List arg0) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(1774317884, arg0); - public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Collections.Generic.List arg0) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-400881550, arg0); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.Collections.Generic.List arg0) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(1774317884, arg0); - public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Collections.Generic.List arg0) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-400881550, arg0); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.Collections.Generic.List arg0) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(1774317884, arg0); + public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Collections.Generic.List arg0) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-400881550, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetStringValuesAsync(global::System.Collections.Generic.List arg0) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(1774317884, arg0); + public global::System.Threading.Tasks.Task GetIntValuesAsync(global::System.Collections.Generic.List arg0) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-400881550, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case 1774317884: // Task GetStringValuesAsync(global::System.Collections.Generic.List arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -400881550: // Task GetIntValuesAsync(global::System.Collections.Generic.List arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case 1774317884: // Task GetStringValuesAsync(global::System.Collections.Generic.List arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -400881550: // Task GetIntValuesAsync(global::System.Collections.Generic.List arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cc5556914..5ce12962f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs index 86e1e53bb..3ab005967 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task GetValuesAsync(global::System.Collections.Generic.List arg0) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-209315513, arg0); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task GetValuesAsync(global::System.Collections.Generic.List arg0) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-209315513, arg0); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetValuesAsync(global::System.Collections.Generic.List arg0) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-209315513, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetValuesAsync(global::System.Collections.Generic.List arg0) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-209315513, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task GetValuesAsync(global::System.Collections.Generic.List arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -209315513: // Task GetValuesAsync(global::System.Collections.Generic.List arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4b5eb605e..4e1919c85 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs index 13abf834f..66b9c688c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs @@ -11,66 +11,71 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1005848884, a); - public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-955516027, a); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1005848884, a); - public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-955516027, a); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-955516027, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject a) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject a) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-955516027, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyGenericObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -955516027: // Task B(global::TempProject.MyGenericObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::TempProject.MyGenericObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -955516027: // Task B(global::TempProject.MyGenericObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5a58eef11..8c11aee07 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0003_TempProject_MyHubClient.g.cs index c4bc909ab..5ea532de4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0003_TempProject_MyHubClient.g.cs @@ -11,73 +11,78 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject> a) - => base.WriteMessageWithResponseAsync>, global::MessagePack.Nil>(-1005848884, a); - public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject>> a) - => base.WriteMessageWithResponseAsync>>, global::MessagePack.Nil>(-955516027, a); - public global::System.Threading.Tasks.Task C(global::TempProject.MyGenericObject>> a) - => base.WriteMessageWithResponseAsync>>, global::MessagePack.Nil>(-972293646, a); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject> a) - => parent.WriteMessageFireAndForgetAsync>, global::MessagePack.Nil>(-1005848884, a); - public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject>> a) - => parent.WriteMessageFireAndForgetAsync>>, global::MessagePack.Nil>(-955516027, a); - public global::System.Threading.Tasks.Task C(global::TempProject.MyGenericObject>> a) - => parent.WriteMessageFireAndForgetAsync>>, global::MessagePack.Nil>(-972293646, a); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject> a) + => base.WriteMessageWithResponseAsync>, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject>> a) + => base.WriteMessageWithResponseAsync>>, global::MessagePack.Nil>(-955516027, a); + public global::System.Threading.Tasks.Task C(global::TempProject.MyGenericObject>> a) + => base.WriteMessageWithResponseAsync>>, global::MessagePack.Nil>(-972293646, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyGenericObject> a) + => parent.WriteMessageFireAndForgetAsync>, global::MessagePack.Nil>(-1005848884, a); + public global::System.Threading.Tasks.Task B(global::TempProject.MyGenericObject>> a) + => parent.WriteMessageFireAndForgetAsync>>, global::MessagePack.Nil>(-955516027, a); + public global::System.Threading.Tasks.Task C(global::TempProject.MyGenericObject>> a) + => parent.WriteMessageFireAndForgetAsync>>, global::MessagePack.Nil>(-972293646, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyGenericObject> a) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -955516027: // Task B(global::TempProject.MyGenericObject>> a) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -972293646: // Task C(global::TempProject.MyGenericObject>> a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::TempProject.MyGenericObject> a) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -955516027: // Task B(global::TempProject.MyGenericObject>> a) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -972293646: // Task C(global::TempProject.MyGenericObject>> a) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cece63905..4bac6483d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0003_TempProject_MyHubClient.g.cs index c498a6a1a..87b41323e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyGenericObject arg0) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-209315513, arg0); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyGenericObject arg0) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-209315513, arg0); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyGenericObject arg0) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-209315513, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetValuesAsync(global::TempProject.MyGenericObject arg0) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-209315513, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task GetValuesAsync(global::TempProject.MyGenericObject arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -209315513: // Task GetValuesAsync(global::TempProject.MyGenericObject arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 7d5c94552..29106145e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs index 45646941f..253098b9c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task GetEnumAsync(global::TempProject.MyGenericObject> arg0) - => base.WriteMessageWithResponseAsync>, global::MessagePack.Nil>(-1221306238, arg0); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task GetEnumAsync(global::TempProject.MyGenericObject> arg0) - => parent.WriteMessageFireAndForgetAsync>, global::MessagePack.Nil>(-1221306238, arg0); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetEnumAsync(global::TempProject.MyGenericObject> arg0) + => base.WriteMessageWithResponseAsync>, global::MessagePack.Nil>(-1221306238, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetEnumAsync(global::TempProject.MyGenericObject> arg0) + => parent.WriteMessageFireAndForgetAsync>, global::MessagePack.Nil>(-1221306238, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1221306238: // Task GetEnumAsync(global::TempProject.MyGenericObject> arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1221306238: // Task GetEnumAsync(global::TempProject.MyGenericObject> arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8fb1d4a66..563c6e0d8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0003_TempProject_MyHubClient.g.cs index ab77fe9d5..5ce667fff 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0003_TempProject_MyHubClient.g.cs @@ -11,66 +11,71 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task> A() - => base.WriteMessageWithResponseAsync>(-1005848884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task> B() - => base.WriteMessageWithResponseAsync>(-955516027, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task> A() - => parent.WriteMessageFireAndForgetAsync>(-1005848884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task> B() - => parent.WriteMessageFireAndForgetAsync>(-955516027, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> A() + => base.WriteMessageWithResponseAsync>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> B() + => base.WriteMessageWithResponseAsync>(-955516027, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> A() + => parent.WriteMessageFireAndForgetAsync>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> B() + => parent.WriteMessageFireAndForgetAsync>(-955516027, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task> A() + base.SetResultForResponse>(taskCompletionSource, data); + break; + case -955516027: // Task> B() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task> A() - base.SetResultForResponse>(taskCompletionSource, data); - break; - case -955516027: // Task> B() - base.SetResultForResponse>(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index dbf14c6ca..0d16a45ab 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index 01b10cf5a..c5a8ded3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -11,87 +11,92 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task GetStringValuesAsync() - => base.WriteMessageWithResponseAsync(1774317884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task GetIntValuesAsync() - => base.WriteMessageWithResponseAsync(-400881550, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task GetInt32ValuesAsync() - => base.WriteMessageWithResponseAsync(309063297, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task GetSingleValuesAsync() - => base.WriteMessageWithResponseAsync(702446639, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task GetBooleanValuesAsync() - => base.WriteMessageWithResponseAsync(2082077357, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task GetStringValuesAsync() - => parent.WriteMessageFireAndForgetAsync(1774317884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task GetIntValuesAsync() - => parent.WriteMessageFireAndForgetAsync(-400881550, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task GetInt32ValuesAsync() - => parent.WriteMessageFireAndForgetAsync(309063297, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task GetSingleValuesAsync() - => parent.WriteMessageFireAndForgetAsync(702446639, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task GetBooleanValuesAsync() - => parent.WriteMessageFireAndForgetAsync(2082077357, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetStringValuesAsync() + => base.WriteMessageWithResponseAsync(1774317884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetIntValuesAsync() + => base.WriteMessageWithResponseAsync(-400881550, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetInt32ValuesAsync() + => base.WriteMessageWithResponseAsync(309063297, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetSingleValuesAsync() + => base.WriteMessageWithResponseAsync(702446639, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetBooleanValuesAsync() + => base.WriteMessageWithResponseAsync(2082077357, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetStringValuesAsync() + => parent.WriteMessageFireAndForgetAsync(1774317884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetIntValuesAsync() + => parent.WriteMessageFireAndForgetAsync(-400881550, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetInt32ValuesAsync() + => parent.WriteMessageFireAndForgetAsync(309063297, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetSingleValuesAsync() + => parent.WriteMessageFireAndForgetAsync(702446639, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task GetBooleanValuesAsync() + => parent.WriteMessageFireAndForgetAsync(2082077357, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case 1774317884: // Task GetStringValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + case -400881550: // Task GetIntValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + case 309063297: // Task GetInt32ValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + case 702446639: // Task GetSingleValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + case 2082077357: // Task GetBooleanValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case 1774317884: // Task GetStringValuesAsync() - base.SetResultForResponse(taskCompletionSource, data); - break; - case -400881550: // Task GetIntValuesAsync() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 309063297: // Task GetInt32ValuesAsync() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 702446639: // Task GetSingleValuesAsync() - base.SetResultForResponse(taskCompletionSource, data); - break; - case 2082077357: // Task GetBooleanValuesAsync() - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c306c1595..4a8cdd678 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs index bdef789ab..c797e7b5b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task GetValuesAsync() - => base.WriteMessageWithResponseAsync(-209315513, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task GetValuesAsync() - => parent.WriteMessageFireAndForgetAsync(-209315513, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task GetValuesAsync() + => base.WriteMessageWithResponseAsync(-209315513, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task GetValuesAsync() + => parent.WriteMessageFireAndForgetAsync(-209315513, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task GetValuesAsync() + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -209315513: // Task GetValuesAsync() - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index ac8cfb352..55eaace57 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0004_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0004_TempProject_MyHubClient.g.cs index e3c181ab4..498c33530 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0004_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0004_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task> GetEnumAsync() - => base.WriteMessageWithResponseAsync>(-1221306238, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task> GetEnumAsync() - => parent.WriteMessageFireAndForgetAsync>(-1221306238, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> GetEnumAsync() + => base.WriteMessageWithResponseAsync>(-1221306238, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> GetEnumAsync() + => parent.WriteMessageFireAndForgetAsync>(-1221306238, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1221306238: // Task> GetEnumAsync() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1221306238: // Task> GetEnumAsync() - base.SetResultForResponse>(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8ac488062..c184bcbe5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index 53c25ace1..3c64184f3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -11,66 +11,71 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task> GetStringValuesAsync() - => base.WriteMessageWithResponseAsync>(1774317884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task> GetIntValuesAsync() - => base.WriteMessageWithResponseAsync>(-400881550, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task> GetStringValuesAsync() - => parent.WriteMessageFireAndForgetAsync>(1774317884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task> GetIntValuesAsync() - => parent.WriteMessageFireAndForgetAsync>(-400881550, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> GetStringValuesAsync() + => base.WriteMessageWithResponseAsync>(1774317884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> GetIntValuesAsync() + => base.WriteMessageWithResponseAsync>(-400881550, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> GetStringValuesAsync() + => parent.WriteMessageFireAndForgetAsync>(1774317884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> GetIntValuesAsync() + => parent.WriteMessageFireAndForgetAsync>(-400881550, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case 1774317884: // Task> GetStringValuesAsync() + base.SetResultForResponse>(taskCompletionSource, data); + break; + case -400881550: // Task> GetIntValuesAsync() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case 1774317884: // Task> GetStringValuesAsync() - base.SetResultForResponse>(taskCompletionSource, data); - break; - case -400881550: // Task> GetIntValuesAsync() - base.SetResultForResponse>(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cc5556914..5ce12962f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs index 24f0ab254..e697a37f0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task> GetValuesAsync() - => base.WriteMessageWithResponseAsync>(-209315513, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task> GetValuesAsync() - => parent.WriteMessageFireAndForgetAsync>(-209315513, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> GetValuesAsync() + => base.WriteMessageWithResponseAsync>(-209315513, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> GetValuesAsync() + => parent.WriteMessageFireAndForgetAsync>(-209315513, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task> GetValuesAsync() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -209315513: // Task> GetValuesAsync() - base.SetResultForResponse>(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4b5eb605e..4e1919c85 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs index 22e953363..ffd1d70d1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs @@ -11,66 +11,71 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task> A() - => base.WriteMessageWithResponseAsync>(-1005848884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task> B() - => base.WriteMessageWithResponseAsync>(-955516027, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task> A() - => parent.WriteMessageFireAndForgetAsync>(-1005848884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task> B() - => parent.WriteMessageFireAndForgetAsync>(-955516027, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> A() + => base.WriteMessageWithResponseAsync>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> B() + => base.WriteMessageWithResponseAsync>(-955516027, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> A() + => parent.WriteMessageFireAndForgetAsync>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> B() + => parent.WriteMessageFireAndForgetAsync>(-955516027, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task> A() + base.SetResultForResponse>(taskCompletionSource, data); + break; + case -955516027: // Task> B() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task> A() - base.SetResultForResponse>(taskCompletionSource, data); - break; - case -955516027: // Task> B() - base.SetResultForResponse>(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5a58eef11..8c11aee07 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0003_TempProject_MyHubClient.g.cs index cfe81fcca..e02826683 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0003_TempProject_MyHubClient.g.cs @@ -11,73 +11,78 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task>> A() - => base.WriteMessageWithResponseAsync>>(-1005848884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task>>> B() - => base.WriteMessageWithResponseAsync>>>(-955516027, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task>>> C() - => base.WriteMessageWithResponseAsync>>>(-972293646, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task>> A() - => parent.WriteMessageFireAndForgetAsync>>(-1005848884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task>>> B() - => parent.WriteMessageFireAndForgetAsync>>>(-955516027, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task>>> C() - => parent.WriteMessageFireAndForgetAsync>>>(-972293646, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task>> A() + => base.WriteMessageWithResponseAsync>>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task>>> B() + => base.WriteMessageWithResponseAsync>>>(-955516027, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task>>> C() + => base.WriteMessageWithResponseAsync>>>(-972293646, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task>> A() + => parent.WriteMessageFireAndForgetAsync>>(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task>>> B() + => parent.WriteMessageFireAndForgetAsync>>>(-955516027, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task>>> C() + => parent.WriteMessageFireAndForgetAsync>>>(-972293646, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task>> A() + base.SetResultForResponse>>(taskCompletionSource, data); + break; + case -955516027: // Task>>> B() + base.SetResultForResponse>>>(taskCompletionSource, data); + break; + case -972293646: // Task>>> C() + base.SetResultForResponse>>>(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task>> A() - base.SetResultForResponse>>(taskCompletionSource, data); - break; - case -955516027: // Task>>> B() - base.SetResultForResponse>>>(taskCompletionSource, data); - break; - case -972293646: // Task>>> C() - base.SetResultForResponse>>>(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cece63905..4bac6483d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0003_TempProject_MyHubClient.g.cs index c62269fe8..4cc480bd6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task> GetValuesAsync() - => base.WriteMessageWithResponseAsync>(-209315513, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task> GetValuesAsync() - => parent.WriteMessageFireAndForgetAsync>(-209315513, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task> GetValuesAsync() + => base.WriteMessageWithResponseAsync>(-209315513, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task> GetValuesAsync() + => parent.WriteMessageFireAndForgetAsync>(-209315513, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -209315513: // Task> GetValuesAsync() + base.SetResultForResponse>(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -209315513: // Task> GetValuesAsync() - base.SetResultForResponse>(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 7d5c94552..29106145e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs index 2fa2e4c92..8bb049ceb 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task>> GetEnumAsync() - => base.WriteMessageWithResponseAsync>>(-1221306238, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task>> GetEnumAsync() - => parent.WriteMessageFireAndForgetAsync>>(-1221306238, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task>> GetEnumAsync() + => base.WriteMessageWithResponseAsync>>(-1221306238, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task>> GetEnumAsync() + => parent.WriteMessageFireAndForgetAsync>>(-1221306238, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1221306238: // Task>> GetEnumAsync() + base.SetResultForResponse>>(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1221306238: // Task>> GetEnumAsync() - base.SetResultForResponse>>(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index fa21effde..31c8bbf32 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs index 34475c9ba..c23619b2f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs @@ -11,75 +11,80 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.Collections.Generic.List> MethodList; - public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIList; - public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIROList; - public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodDictionary; - public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIDictionary; - public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIRODictionary; - public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIEnumerable; - public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodICollection; - public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIROCollection; - public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodILookup; - public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIGrouping; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.MethodList = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType, global::System.Collections.Generic.List>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodList", serializerProvider); - this.MethodIList = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIList", serializerProvider); - this.MethodIROList = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIROList", serializerProvider); - this.MethodDictionary = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodDictionary", serializerProvider); - this.MethodIDictionary = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIDictionary", serializerProvider); - this.MethodIRODictionary = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIRODictionary", serializerProvider); - this.MethodIEnumerable = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIEnumerable", serializerProvider); - this.MethodICollection = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodICollection", serializerProvider); - this.MethodIROCollection = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIROCollection", serializerProvider); - this.MethodILookup = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodILookup", serializerProvider); - this.MethodIGrouping = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIGrouping", serializerProvider); - } - } + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.Collections.Generic.List> MethodList; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIList; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIROList; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodDictionary; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIDictionary; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIRODictionary; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIEnumerable; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodICollection; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIROCollection; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodILookup; + public global::MagicOnion.Client.Internal.RawMethodInvoker> MethodIGrouping; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.MethodList = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType, global::System.Collections.Generic.List>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodList", serializerProvider); + this.MethodIList = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIList", serializerProvider); + this.MethodIROList = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIROList", serializerProvider); + this.MethodDictionary = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodDictionary", serializerProvider); + this.MethodIDictionary = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIDictionary", serializerProvider); + this.MethodIRODictionary = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIRODictionary", serializerProvider); + this.MethodIEnumerable = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIEnumerable", serializerProvider); + this.MethodICollection = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodICollection", serializerProvider); + this.MethodIROCollection = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIROCollection", serializerProvider); + this.MethodILookup = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodILookup", serializerProvider); + this.MethodIGrouping = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "MethodIGrouping", serializerProvider); + } + } - readonly ClientCore core; + readonly ClientCore core; - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); - public global::MagicOnion.UnaryResult> MethodList(global::System.Collections.Generic.List args) - => this.core.MethodList.InvokeUnary(this, "IMyService/MethodList", args); - public global::MagicOnion.UnaryResult> MethodIList() - => this.core.MethodIList.InvokeUnary(this, "IMyService/MethodIList", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> MethodIROList() - => this.core.MethodIROList.InvokeUnary(this, "IMyService/MethodIROList", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> MethodDictionary() - => this.core.MethodDictionary.InvokeUnary(this, "IMyService/MethodDictionary", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> MethodIDictionary() - => this.core.MethodIDictionary.InvokeUnary(this, "IMyService/MethodIDictionary", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> MethodIRODictionary() - => this.core.MethodIRODictionary.InvokeUnary(this, "IMyService/MethodIRODictionary", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> MethodIEnumerable() - => this.core.MethodIEnumerable.InvokeUnary(this, "IMyService/MethodIEnumerable", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> MethodICollection() - => this.core.MethodICollection.InvokeUnary(this, "IMyService/MethodICollection", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> MethodIROCollection() - => this.core.MethodIROCollection.InvokeUnary(this, "IMyService/MethodIROCollection", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> MethodILookup() - => this.core.MethodILookup.InvokeUnary(this, "IMyService/MethodILookup", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> MethodIGrouping() - => this.core.MethodIGrouping.InvokeUnary(this, "IMyService/MethodIGrouping", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodList(global::System.Collections.Generic.List args) + => this.core.MethodList.InvokeUnary(this, "IMyService/MethodList", args); + public global::MagicOnion.UnaryResult> MethodIList() + => this.core.MethodIList.InvokeUnary(this, "IMyService/MethodIList", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIROList() + => this.core.MethodIROList.InvokeUnary(this, "IMyService/MethodIROList", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodDictionary() + => this.core.MethodDictionary.InvokeUnary(this, "IMyService/MethodDictionary", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIDictionary() + => this.core.MethodIDictionary.InvokeUnary(this, "IMyService/MethodIDictionary", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIRODictionary() + => this.core.MethodIRODictionary.InvokeUnary(this, "IMyService/MethodIRODictionary", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIEnumerable() + => this.core.MethodIEnumerable.InvokeUnary(this, "IMyService/MethodIEnumerable", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodICollection() + => this.core.MethodICollection.InvokeUnary(this, "IMyService/MethodICollection", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIROCollection() + => this.core.MethodIROCollection.InvokeUnary(this, "IMyService/MethodIROCollection", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodILookup() + => this.core.MethodILookup.InvokeUnary(this, "IMyService/MethodILookup", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> MethodIGrouping() + => this.core.MethodIGrouping.InvokeUnary(this, "IMyService/MethodIGrouping", global::MessagePack.Nil.Default); + } + } } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 713968d21..7795c640b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs index 463a5fa97..5c9013aee 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs @@ -11,43 +11,48 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> A; - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> B; - public global::MagicOnion.Client.Internal.RawMethodInvoker>> C; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); - this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); - this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> B; + public global::MagicOnion.Client.Internal.RawMethodInvoker>> C; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A(global::TempProject.MyGenericObject a) + => this.core.A.InvokeUnary(this, "IMyService/A", a); + public global::MagicOnion.UnaryResult B(global::TempProject.MyGenericObject a) + => this.core.B.InvokeUnary(this, "IMyService/B", a); + public global::MagicOnion.UnaryResult>> C() + => this.core.C.InvokeUnary(this, "IMyService/C", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult A(global::TempProject.MyGenericObject a) - => this.core.A.InvokeUnary(this, "IMyService/A", a); - public global::MagicOnion.UnaryResult B(global::TempProject.MyGenericObject a) - => this.core.B.InvokeUnary(this, "IMyService/B", a); - public global::MagicOnion.UnaryResult>> C() - => this.core.C.InvokeUnary(this, "IMyService/C", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index dbf14c6ca..0d16a45ab 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index 59427b189..563f427c1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -11,51 +11,56 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker GetStringValuesAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker GetIntValuesAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker GetInt32ValuesAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker GetSingleValuesAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker GetBooleanValuesAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); - this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); - this.GetInt32ValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetInt32ValuesAsync", serializerProvider); - this.GetSingleValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetSingleValuesAsync", serializerProvider); - this.GetBooleanValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetBooleanValuesAsync", serializerProvider); - } - } + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetStringValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetIntValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetInt32ValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetSingleValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetBooleanValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); + this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); + this.GetInt32ValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetInt32ValuesAsync", serializerProvider); + this.GetSingleValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetSingleValuesAsync", serializerProvider); + this.GetBooleanValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetBooleanValuesAsync", serializerProvider); + } + } - readonly ClientCore core; + readonly ClientCore core; - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); - public global::MagicOnion.UnaryResult GetStringValuesAsync(global::System.String[] arg0) - => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", arg0); - public global::MagicOnion.UnaryResult GetIntValuesAsync(global::System.Int32[] arg0) - => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", arg0); - public global::MagicOnion.UnaryResult GetInt32ValuesAsync(global::System.Int32[] arg0) - => this.core.GetInt32ValuesAsync.InvokeUnary(this, "IMyService/GetInt32ValuesAsync", arg0); - public global::MagicOnion.UnaryResult GetSingleValuesAsync(global::System.Single[] arg0) - => this.core.GetSingleValuesAsync.InvokeUnary(this, "IMyService/GetSingleValuesAsync", arg0); - public global::MagicOnion.UnaryResult GetBooleanValuesAsync(global::System.Boolean[] arg0) - => this.core.GetBooleanValuesAsync.InvokeUnary(this, "IMyService/GetBooleanValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetStringValuesAsync(global::System.String[] arg0) + => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetIntValuesAsync(global::System.Int32[] arg0) + => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetInt32ValuesAsync(global::System.Int32[] arg0) + => this.core.GetInt32ValuesAsync.InvokeUnary(this, "IMyService/GetInt32ValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetSingleValuesAsync(global::System.Single[] arg0) + => this.core.GetSingleValuesAsync.InvokeUnary(this, "IMyService/GetSingleValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetBooleanValuesAsync(global::System.Boolean[] arg0) + => this.core.GetBooleanValuesAsync.InvokeUnary(this, "IMyService/GetBooleanValuesAsync", arg0); + } + } } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c306c1595..4a8cdd678 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index 9867a7b28..f630384e8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker GetValuesAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetValuesAsync(global::TempProject.MyResponse[] arg0) + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult GetValuesAsync(global::TempProject.MyResponse[] arg0) - => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8ac488062..c184bcbe5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index b3f3d7767..3658dae21 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -11,39 +11,44 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetStringValuesAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetIntValuesAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); - this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetStringValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetIntValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); + this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetStringValuesAsync(global::System.Collections.Generic.List arg0) + => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", arg0); + public global::MagicOnion.UnaryResult GetIntValuesAsync(global::System.Collections.Generic.List arg0) + => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", arg0); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult GetStringValuesAsync(global::System.Collections.Generic.List arg0) - => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", arg0); - public global::MagicOnion.UnaryResult GetIntValuesAsync(global::System.Collections.Generic.List arg0) - => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", arg0); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cc5556914..5ce12962f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index edbd8856f..923742ba3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetValuesAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetValuesAsync(global::System.Collections.Generic.List arg0) + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult GetValuesAsync(global::System.Collections.Generic.List arg0) - => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5a58eef11..8c11aee07 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs index a0798b9c7..5875ffdd9 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs @@ -11,43 +11,48 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker>, global::MessagePack.Nil> A; - public global::MagicOnion.Client.Internal.RawMethodInvoker>>, global::MessagePack.Nil> B; - public global::MagicOnion.Client.Internal.RawMethodInvoker>>, global::MessagePack.Nil> C; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); - this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); - this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker>, global::MessagePack.Nil> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker>>, global::MessagePack.Nil> B; + public global::MagicOnion.Client.Internal.RawMethodInvoker>>, global::MessagePack.Nil> C; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A(global::TempProject.MyGenericObject> a) + => this.core.A.InvokeUnary(this, "IMyService/A", a); + public global::MagicOnion.UnaryResult B(global::TempProject.MyGenericObject>> a) + => this.core.B.InvokeUnary(this, "IMyService/B", a); + public global::MagicOnion.UnaryResult C(global::TempProject.MyGenericObject>> a) + => this.core.C.InvokeUnary(this, "IMyService/C", a); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult A(global::TempProject.MyGenericObject> a) - => this.core.A.InvokeUnary(this, "IMyService/A", a); - public global::MagicOnion.UnaryResult B(global::TempProject.MyGenericObject>> a) - => this.core.B.InvokeUnary(this, "IMyService/B", a); - public global::MagicOnion.UnaryResult C(global::TempProject.MyGenericObject>> a) - => this.core.C.InvokeUnary(this, "IMyService/C", a); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cece63905..4bac6483d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs index 486815da8..55b53a323 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetValuesAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MessagePack.Nil> GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetValuesAsync(global::TempProject.MyGenericObject arg0) + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult GetValuesAsync(global::TempProject.MyGenericObject arg0) - => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", arg0); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 7d5c94552..29106145e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs index bbe889b41..ac1628b0a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker>, global::MessagePack.Nil> GetEnumAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker>, global::MessagePack.Nil> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetEnumAsync(global::TempProject.MyGenericObject> arg0) + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", arg0); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult GetEnumAsync(global::TempProject.MyGenericObject> arg0) - => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", arg0); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8fb1d4a66..563c6e0d8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs index f1959bbd7..c8c98a4d1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs @@ -11,39 +11,44 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker> A; - public global::MagicOnion.Client.Internal.RawMethodInvoker> B; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); - this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker> B; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> B() + => this.core.B.InvokeUnary(this, "IMyService/B", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult> A() - => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> B() - => this.core.B.InvokeUnary(this, "IMyService/B", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index dbf14c6ca..0d16a45ab 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index e706eaa13..66c75caa4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -11,51 +11,56 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker GetStringValuesAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker GetIntValuesAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker GetInt32ValuesAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker GetSingleValuesAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker GetBooleanValuesAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); - this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); - this.GetInt32ValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetInt32ValuesAsync", serializerProvider); - this.GetSingleValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetSingleValuesAsync", serializerProvider); - this.GetBooleanValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetBooleanValuesAsync", serializerProvider); - } - } + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetStringValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetIntValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetInt32ValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetSingleValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker GetBooleanValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); + this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); + this.GetInt32ValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetInt32ValuesAsync", serializerProvider); + this.GetSingleValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetSingleValuesAsync", serializerProvider); + this.GetBooleanValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetBooleanValuesAsync", serializerProvider); + } + } - readonly ClientCore core; + readonly ClientCore core; - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); - public global::MagicOnion.UnaryResult GetStringValuesAsync() - => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult GetIntValuesAsync() - => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult GetInt32ValuesAsync() - => this.core.GetInt32ValuesAsync.InvokeUnary(this, "IMyService/GetInt32ValuesAsync", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult GetSingleValuesAsync() - => this.core.GetSingleValuesAsync.InvokeUnary(this, "IMyService/GetSingleValuesAsync", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult GetBooleanValuesAsync() - => this.core.GetBooleanValuesAsync.InvokeUnary(this, "IMyService/GetBooleanValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult GetStringValuesAsync() + => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult GetIntValuesAsync() + => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult GetInt32ValuesAsync() + => this.core.GetInt32ValuesAsync.InvokeUnary(this, "IMyService/GetInt32ValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult GetSingleValuesAsync() + => this.core.GetSingleValuesAsync.InvokeUnary(this, "IMyService/GetSingleValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult GetBooleanValuesAsync() + => this.core.GetBooleanValuesAsync.InvokeUnary(this, "IMyService/GetBooleanValuesAsync", global::MessagePack.Nil.Default); + } + } } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c306c1595..4a8cdd678 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index 5f2703b5e..0dddf7e04 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker GetValuesAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult GetValuesAsync() + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult GetValuesAsync() - => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index ac8cfb352..55eaace57 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs index 16add03ce..76ebdd25c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker> GetEnumAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> GetEnumAsync() + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult> GetEnumAsync() - => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8ac488062..c184bcbe5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index b8b80226e..079626789 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -11,39 +11,44 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker> GetStringValuesAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker> GetIntValuesAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); - this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetStringValuesAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetIntValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetStringValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetStringValuesAsync", serializerProvider); + this.GetIntValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetIntValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> GetStringValuesAsync() + => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> GetIntValuesAsync() + => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult> GetStringValuesAsync() - => this.core.GetStringValuesAsync.InvokeUnary(this, "IMyService/GetStringValuesAsync", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> GetIntValuesAsync() - => this.core.GetIntValuesAsync.InvokeUnary(this, "IMyService/GetIntValuesAsync", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cc5556914..5ce12962f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index 266cc6d1b..b4cb9cfaa 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker> GetValuesAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> GetValuesAsync() + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult> GetValuesAsync() - => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4b5eb605e..4e1919c85 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs index 104f38d02..0ccfa3133 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs @@ -11,39 +11,44 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker> A; - public global::MagicOnion.Client.Internal.RawMethodInvoker> B; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); - this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker> B; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult> B() + => this.core.B.InvokeUnary(this, "IMyService/B", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult> A() - => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult> B() - => this.core.B.InvokeUnary(this, "IMyService/B", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5a58eef11..8c11aee07 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs index 6e926b04e..65b42b07a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs @@ -11,43 +11,48 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker>> A; - public global::MagicOnion.Client.Internal.RawMethodInvoker>>> B; - public global::MagicOnion.Client.Internal.RawMethodInvoker>>> C; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); - this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); - this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker>> A; + public global::MagicOnion.Client.Internal.RawMethodInvoker>>> B; + public global::MagicOnion.Client.Internal.RawMethodInvoker>>> C; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + this.B = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>>(global::Grpc.Core.MethodType.Unary, "IMyService", "B", serializerProvider); + this.C = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>>(global::Grpc.Core.MethodType.Unary, "IMyService", "C", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult>> A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult>>> B() + => this.core.B.InvokeUnary(this, "IMyService/B", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult>>> C() + => this.core.C.InvokeUnary(this, "IMyService/C", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult>> A() - => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult>>> B() - => this.core.B.InvokeUnary(this, "IMyService/B", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult>>> C() - => this.core.C.InvokeUnary(this, "IMyService/C", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cece63905..4bac6483d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs index 338c33d8d..9ca5633f2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker> GetValuesAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker> GetValuesAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetValuesAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetValuesAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult> GetValuesAsync() + => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult> GetValuesAsync() - => this.core.GetValuesAsync.InvokeUnary(this, "IMyService/GetValuesAsync", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 7d5c94552..29106145e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs index 80a8b1c2c..619f15603 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker>> GetEnumAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker>> GetEnumAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.GetEnumAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType>>(global::Grpc.Core.MethodType.Unary, "IMyService", "GetEnumAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult>> GetEnumAsync() + => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult>> GetEnumAsync() - => this.core.GetEnumAsync.InvokeUnary(this, "IMyService/GetEnumAsync", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c3fd4e177..58cded831 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs index 67b55e64f..dbffc1b11 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs @@ -11,43 +11,48 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker ClientStreamingAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker ServerStreamingAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker DuplexStreamingAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.ClientStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.ClientStreaming, "IMyService", "ClientStreamingAsync", serializerProvider); - this.ServerStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.ServerStreaming, "IMyService", "ServerStreamingAsync", serializerProvider); - this.DuplexStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.DuplexStreaming, "IMyService", "DuplexStreamingAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker ClientStreamingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker ServerStreamingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker DuplexStreamingAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.ClientStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.ClientStreaming, "IMyService", "ClientStreamingAsync", serializerProvider); + this.ServerStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.ServerStreaming, "IMyService", "ServerStreamingAsync", serializerProvider); + this.DuplexStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.DuplexStreaming, "IMyService", "DuplexStreamingAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::System.Threading.Tasks.Task> ClientStreamingAsync() + => this.core.ClientStreamingAsync.InvokeClientStreaming(this, "IMyService/ClientStreamingAsync"); + public global::System.Threading.Tasks.Task> ServerStreamingAsync() + => this.core.ServerStreamingAsync.InvokeServerStreaming(this, "IMyService/ServerStreamingAsync", global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> DuplexStreamingAsync() + => this.core.DuplexStreamingAsync.InvokeDuplexStreaming(this, "IMyService/DuplexStreamingAsync"); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::System.Threading.Tasks.Task> ClientStreamingAsync() - => this.core.ClientStreamingAsync.InvokeClientStreaming(this, "IMyService/ClientStreamingAsync"); - public global::System.Threading.Tasks.Task> ServerStreamingAsync() - => this.core.ServerStreamingAsync.InvokeServerStreaming(this, "IMyService/ServerStreamingAsync", global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task> DuplexStreamingAsync() - => this.core.DuplexStreamingAsync.InvokeDuplexStreaming(this, "IMyService/DuplexStreamingAsync"); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 469652ca8..d1f1df5f6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs index d97a8bdb2..2b2329640 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 469652ca8..d1f1df5f6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index d97a8bdb2..2b2329640 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 469652ca8..d1f1df5f6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs index d97a8bdb2..2b2329640 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 469652ca8..d1f1df5f6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index d97a8bdb2..2b2329640 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c3fd4e177..58cded831 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs index 67b55e64f..dbffc1b11 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs @@ -11,43 +11,48 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker ClientStreamingAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker ServerStreamingAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker DuplexStreamingAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.ClientStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.ClientStreaming, "IMyService", "ClientStreamingAsync", serializerProvider); - this.ServerStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.ServerStreaming, "IMyService", "ServerStreamingAsync", serializerProvider); - this.DuplexStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.DuplexStreaming, "IMyService", "DuplexStreamingAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker ClientStreamingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker ServerStreamingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker DuplexStreamingAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.ClientStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.ClientStreaming, "IMyService", "ClientStreamingAsync", serializerProvider); + this.ServerStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.ServerStreaming, "IMyService", "ServerStreamingAsync", serializerProvider); + this.DuplexStreamingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_RefType(global::Grpc.Core.MethodType.DuplexStreaming, "IMyService", "DuplexStreamingAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::System.Threading.Tasks.Task> ClientStreamingAsync() + => this.core.ClientStreamingAsync.InvokeClientStreaming(this, "IMyService/ClientStreamingAsync"); + public global::System.Threading.Tasks.Task> ServerStreamingAsync() + => this.core.ServerStreamingAsync.InvokeServerStreaming(this, "IMyService/ServerStreamingAsync", global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task> DuplexStreamingAsync() + => this.core.DuplexStreamingAsync.InvokeDuplexStreaming(this, "IMyService/DuplexStreamingAsync"); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::System.Threading.Tasks.Task> ClientStreamingAsync() - => this.core.ClientStreamingAsync.InvokeClientStreaming(this, "IMyService/ClientStreamingAsync"); - public global::System.Threading.Tasks.Task> ServerStreamingAsync() - => this.core.ServerStreamingAsync.InvokeServerStreaming(this, "IMyService/ServerStreamingAsync", global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task> DuplexStreamingAsync() - => this.core.DuplexStreamingAsync.InvokeDuplexStreaming(this, "IMyService/DuplexStreamingAsync"); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 2525378cb..5120f1251 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs index 0e3178033..c8aacfd1b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker A; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A() + => this.core.A.InvokeUnaryNonGeneric(this, "IMyService/A", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult A() - => this.core.A.InvokeUnaryNonGeneric(this, "IMyService/A", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c3fd4e177..58cded831 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs index e1c34dd8d..093fda01d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker A; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult A() - => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index eea855741..7479234db 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs index 8c6701050..ea461762e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker A; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult A() - => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 7507c8651..026347273 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs index 1e83af852..d239a4cfc 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker A; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult A() - => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 0af36aae5..a7393bfc7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0003_TempProject_MyHubClient.g.cs index 98d474bd6..06b773a9d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0003_TempProject_MyHubClient.g.cs @@ -11,105 +11,110 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A() - => base.WriteMessageWithResponseAsync(-1005848884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task B(global::TempProject.MyObject a) - => base.WriteMessageWithResponseAsync(-955516027, a); - public global::System.Threading.Tasks.Task C(global::TempProject.MyObject a, global::System.String b) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-972293646, new global::MagicOnion.DynamicArgumentTuple(a, b)); - public global::System.Threading.Tasks.Task D(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1056181741, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); - public global::System.Threading.Tasks.Task E(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) - => base.WriteMessageWithResponseAsync, global::System.Int32>(-1072959360, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A() - => parent.WriteMessageFireAndForgetAsync(-1005848884, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task B(global::TempProject.MyObject a) - => parent.WriteMessageFireAndForgetAsync(-955516027, a); - public global::System.Threading.Tasks.Task C(global::TempProject.MyObject a, global::System.String b) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-972293646, new global::MagicOnion.DynamicArgumentTuple(a, b)); - public global::System.Threading.Tasks.Task D(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1056181741, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); - public global::System.Threading.Tasks.Task E(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) - => parent.WriteMessageFireAndForgetAsync, global::System.Int32>(-1072959360, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1262822265: // Void OnMessage() - { - var value = base.Deserialize(data); - receiver.OnMessage(); - } - break; - case 925462767: // Void OnMessage2(global::TempProject.MyObject a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A() + => base.WriteMessageWithResponseAsync(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task B(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-955516027, a); + public global::System.Threading.Tasks.Task C(global::TempProject.MyObject a, global::System.String b) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-972293646, new global::MagicOnion.DynamicArgumentTuple(a, b)); + public global::System.Threading.Tasks.Task D(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1056181741, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); + public global::System.Threading.Tasks.Task E(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + => base.WriteMessageWithResponseAsync, global::System.Int32>(-1072959360, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A() + => parent.WriteMessageFireAndForgetAsync(-1005848884, global::MessagePack.Nil.Default); + public global::System.Threading.Tasks.Task B(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-955516027, a); + public global::System.Threading.Tasks.Task C(global::TempProject.MyObject a, global::System.String b) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-972293646, new global::MagicOnion.DynamicArgumentTuple(a, b)); + public global::System.Threading.Tasks.Task D(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1056181741, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); + public global::System.Threading.Tasks.Task E(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + => parent.WriteMessageFireAndForgetAsync, global::System.Int32>(-1072959360, new global::MagicOnion.DynamicArgumentTuple(a, b, c)); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize(data); - receiver.OnMessage2(value); + case -1262822265: // Void OnMessage() + { + var value = base.Deserialize(data); + receiver.OnMessage(); + } + break; + case 925462767: // Void OnMessage2(global::TempProject.MyObject a) + { + var value = base.Deserialize(data); + receiver.OnMessage2(value); + } + break; + case 908685148: // Void OnMessage3(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + { + var value = base.Deserialize>(data); + receiver.OnMessage3(value.Item1, value.Item2, value.Item3); + } + break; } - break; - case 908685148: // Void OnMessage3(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.OnMessage3(value.Item1, value.Item2, value.Item3); + case -1005848884: // Task A() + base.SetResultForResponse(taskCompletionSource, data); + break; + case -955516027: // Task B(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -972293646: // Task C(global::TempProject.MyObject a, global::System.String b) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -1056181741: // Task D(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + base.SetResultForResponse(taskCompletionSource, data); + break; + case -1072959360: // Task E(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) + base.SetResultForResponse(taskCompletionSource, data); + break; } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A() - base.SetResultForResponse(taskCompletionSource, data); - break; - case -955516027: // Task B(global::TempProject.MyObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -972293646: // Task C(global::TempProject.MyObject a, global::System.String b) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -1056181741: // Task D(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -1072959360: // Task E(global::TempProject.MyObject a, global::System.String b, global::System.Int32 c) - base.SetResultForResponse(taskCompletionSource, data); - break; + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 03e854624..4afdfc23d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0003_TempProject_MyHubClient.g.cs index 90cf75177..c7e9d1f76 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0003_TempProject_MyHubClient.g.cs @@ -11,65 +11,70 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) - => base.WriteMessageWithResponseAsync(-1005848884, a); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) - => parent.WriteMessageFireAndForgetAsync(-1005848884, a); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1262822265: // Void OnMessage(global::TempProject.MyObject arg0, global::System.Int32 arg1, global::System.String arg2) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize>(data); - receiver.OnMessage(value.Item1, value.Item2, value.Item3); + case -1262822265: // Void OnMessage(global::TempProject.MyObject arg0, global::System.Int32 arg1, global::System.String arg2) + { + var value = base.Deserialize>(data); + receiver.OnMessage(value.Item1, value.Item2, value.Item3); + } + break; } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::TempProject.MyObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 1531302d2..89f7d8aaf 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0003_TempProject_MyHubClient.g.cs index 717ca2e2c..3a271afd1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0003_TempProject_MyHubClient.g.cs @@ -11,65 +11,70 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) - => base.WriteMessageWithResponseAsync(-1005848884, a); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) - => parent.WriteMessageFireAndForgetAsync(-1005848884, a); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1262822265: // Void OnMessage(global::TempProject.MyObject arg0) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize(data); - receiver.OnMessage(value); + case -1262822265: // Void OnMessage(global::TempProject.MyObject arg0) + { + var value = base.Deserialize(data); + receiver.OnMessage(value); + } + break; } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::TempProject.MyObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 1531302d2..89f7d8aaf 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0003_TempProject_MyHubClient.g.cs index e80c0ee74..3b828a34a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0003_TempProject_MyHubClient.g.cs @@ -11,65 +11,70 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) - => base.WriteMessageWithResponseAsync(-1005848884, a); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) - => parent.WriteMessageFireAndForgetAsync(-1005848884, a); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1262822265: // Void OnMessage() + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize(data); - receiver.OnMessage(); + case -1262822265: // Void OnMessage() + { + var value = base.Deserialize(data); + receiver.OnMessage(); + } + break; } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::TempProject.MyObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 469652ca8..d1f1df5f6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs index d97a8bdb2..2b2329640 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 469652ca8..d1f1df5f6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs index d97a8bdb2..2b2329640 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 85602e542..2f84d83f5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0003_TempProject_MyHubClient.g.cs index e9d0397b7..746553f75 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::System.String arg0, global::System.Int32 arg1, global::System.Boolean arg2) - => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1005848884, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::System.String arg0, global::System.Int32 arg1, global::System.Boolean arg2) - => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1005848884, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::System.String arg0, global::System.Int32 arg1, global::System.Boolean arg2) + => base.WriteMessageWithResponseAsync, global::MessagePack.Nil>(-1005848884, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::System.String arg0, global::System.Int32 arg1, global::System.Boolean arg2) + => parent.WriteMessageFireAndForgetAsync, global::MessagePack.Nil>(-1005848884, new global::MagicOnion.DynamicArgumentTuple(arg0, arg1, arg2)); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::System.String arg0, global::System.Int32 arg1, global::System.Boolean arg2) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::System.String arg0, global::System.Int32 arg1, global::System.Boolean arg2) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c3fd4e177..58cded831 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0003_TempProject_MyHubClient.g.cs index f1c516f3a..8fa1ecc22 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::System.String arg0) - => base.WriteMessageWithResponseAsync(-1005848884, arg0); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::System.String arg0) - => parent.WriteMessageFireAndForgetAsync(-1005848884, arg0); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::System.String arg0) + => base.WriteMessageWithResponseAsync(-1005848884, arg0); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::System.String arg0) + => parent.WriteMessageFireAndForgetAsync(-1005848884, arg0); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::System.String arg0) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::System.String arg0) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 2525378cb..5120f1251 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0003_TempProject_MyHubClient.g.cs index 0bb64c138..f2b3eea9d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A() - => base.WriteMessageWithResponseAsync(-1005848884, global::MessagePack.Nil.Default); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A() - => parent.WriteMessageFireAndForgetAsync(-1005848884, global::MessagePack.Nil.Default); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A() + => base.WriteMessageWithResponseAsync(-1005848884, global::MessagePack.Nil.Default); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A() + => parent.WriteMessageFireAndForgetAsync(-1005848884, global::MessagePack.Nil.Default); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A() + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A() - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 1531302d2..89f7d8aaf 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0003_TempProject_MyHubClient.g.cs index e697627d7..52281c601 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) - => base.WriteMessageWithResponseAsync(-1005848884, a); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) - => parent.WriteMessageFireAndForgetAsync(-1005848884, a); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::TempProject.MyObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 16d29ad3f..6cb3caa6c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0003_TempProject_MyHubClient.g.cs index 7d192b047..c747de18f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) - => base.WriteMessageWithResponseAsync(-1005848884, a); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) - => parent.WriteMessageFireAndForgetAsync(-1005848884, a); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::TempProject.MyObject a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::TempProject.MyObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 1531302d2..89f7d8aaf 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0003_TempProject_MyHubClient.g.cs index 9641b3f9c..10b78dec5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) - => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(-1005848884, a)); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) - => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(-1005848884, a)); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) + => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(-1005848884, a)); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) + => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(-1005848884, a)); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // ValueTask A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // ValueTask A(global::TempProject.MyObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 16d29ad3f..6cb3caa6c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs index 49a521457..a50cde281 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs @@ -11,59 +11,64 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) - => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(-1005848884, a)); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub - { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) - => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(-1005848884, a)); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + static partial class MagicOnionGeneratedClient { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) + => new global::System.Threading.Tasks.ValueTask(base.WriteMessageWithResponseAsync(-1005848884, a)); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.ValueTask A(global::TempProject.MyObject a) + => new global::System.Threading.Tasks.ValueTask(parent.WriteMessageFireAndForgetAsync(-1005848884, a)); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) + { + } + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // ValueTask A(global::TempProject.MyObject a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // ValueTask A(global::TempProject.MyObject a) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs index 25bf3b16b..e59d8e942 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs @@ -11,43 +11,48 @@ namespace MyApplication1 using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker PingAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker CanGreetAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class MyApplication1_GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService { - this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); - this.PingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "PingAsync", serializerProvider); - this.CanGreetAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "CanGreetAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker PingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker CanGreetAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + this.PingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "PingAsync", serializerProvider); + this.CanGreetAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "CanGreetAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyApplication1_GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyApplication1_GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyApplication1_GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + public global::MagicOnion.UnaryResult PingAsync() + => this.core.PingAsync.InvokeUnaryNonGeneric(this, "IGreeterService/PingAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult CanGreetAsync() + => this.core.CanGreetAsync.InvokeUnary(this, "IGreeterService/CanGreetAsync", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new GreeterServiceClient(options, core); - - public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) - => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); - public global::MagicOnion.UnaryResult PingAsync() - => this.core.PingAsync.InvokeUnaryNonGeneric(this, "IGreeterService/PingAsync", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult CanGreetAsync() - => this.core.CanGreetAsync.InvokeUnary(this, "IGreeterService/CanGreetAsync", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index 0ffa2328e..aa72737d8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace MyApplication1 partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs index 3327da194..c05207373 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyApplication1_GreeterServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..4a8c8c00d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,23 @@ +// +namespace MagicOnion.Client +{ + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + public bool DisableAutoRegister { get; init; } + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + internal enum GenerateSerializerType + { + MessagePack, + MemoryPack + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0001_MyApplication1_Net_Remoting_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0001_MyApplication1_Net_Remoting_GreeterServiceClient.g.cs new file mode 100644 index 000000000..047ce82a1 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0001_MyApplication1_Net_Remoting_GreeterServiceClient.g.cs @@ -0,0 +1,58 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyApplication1.Net.Remoting +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static partial class MagicOnionGeneratedClient + { + [global::MagicOnion.Ignore] + public class MyApplication1_Net_Remoting_GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.Net.Remoting.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker PingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker CanGreetAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + this.PingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "PingAsync", serializerProvider); + this.CanGreetAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "CanGreetAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyApplication1_Net_Remoting_GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyApplication1_Net_Remoting_GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyApplication1_Net_Remoting_GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + public global::MagicOnion.UnaryResult PingAsync() + => this.core.PingAsync.InvokeUnaryNonGeneric(this, "IGreeterService/PingAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult CanGreetAsync() + => this.core.CanGreetAsync.InvokeUnary(this, "IGreeterService/CanGreetAsync", global::MessagePack.Nil.Default); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..ef51a1d9e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyApplication1.Net.Remoting +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_Remoting_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_Remoting_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..79fe273ba --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_Remoting_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace Remoting +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..52e4e4183 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs @@ -0,0 +1,85 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace MyApplication1.Net.Remoting +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => TryRegisterProviderFactory(); + + public static bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.Net.Remoting.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyApplication1_Net_Remoting_GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_Remoting_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_Remoting_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..f5a8bc55d --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_Remoting_MagicOnionInitializer.g.cs @@ -0,0 +1,87 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace Remoting +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + bool isRegistered = false; + readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static MagicOnionInitializer Instance { get; } = new(); + + public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + static void Register() => Instance.TryRegisterProviderFactory(); + + public bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.Net.Remoting.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyApplication1_Net_Remoting_GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs index c63f6ebf1..43dd2e11a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace MyNamespace partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs index 802025152..f9ff01e88 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::MyNamespace.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyNamespace.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyNamespace_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs index 36b4527b1..6a3318886 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace MyNamespace using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyNamespace.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>, global::MessagePack.Nil> A; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class MyNamespace_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyNamespace.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>, global::MessagePack.Nil> A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>, global::MessagePack.Nil>(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public MyNamespace_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyNamespace_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyNamespace_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A(global::System.Int32 arg0, global::System.Collections.Generic.IReadOnlyList arg1, global::System.IO.FileMode arg2, global::System.Linq.ILookup arg3, global::System.Net.Http.ClientCertificateOption arg4, global::System.Threading.ApartmentState arg5, global::System.Threading.Tasks.TaskCreationOptions arg6) + => this.core.A.InvokeUnary(this, "IMyService/A", new global::MagicOnion.DynamicArgumentTuple, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult A(global::System.Int32 arg0, global::System.Collections.Generic.IReadOnlyList arg1, global::System.IO.FileMode arg2, global::System.Linq.ILookup arg3, global::System.Net.Http.ClientCertificateOption arg4, global::System.Threading.ApartmentState arg5, global::System.Threading.Tasks.TaskCreationOptions arg6) - => this.core.A.InvokeUnary(this, "IMyService/A", new global::MagicOnion.DynamicArgumentTuple, global::System.IO.FileMode, global::System.Linq.ILookup, global::System.Net.Http.ClientCertificateOption, global::System.Threading.ApartmentState, global::System.Threading.Tasks.TaskCreationOptions>(arg0, arg1, arg2, arg3, arg4, arg5, arg6)); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs index 25bf3b16b..e59d8e942 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs @@ -11,43 +11,48 @@ namespace MyApplication1 using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker PingAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker CanGreetAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class MyApplication1_GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService { - this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); - this.PingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "PingAsync", serializerProvider); - this.CanGreetAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "CanGreetAsync", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker PingAsync; + public global::MagicOnion.Client.Internal.RawMethodInvoker CanGreetAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + this.PingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "PingAsync", serializerProvider); + this.CanGreetAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "CanGreetAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyApplication1_GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyApplication1_GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyApplication1_GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + public global::MagicOnion.UnaryResult PingAsync() + => this.core.PingAsync.InvokeUnaryNonGeneric(this, "IGreeterService/PingAsync", global::MessagePack.Nil.Default); + public global::MagicOnion.UnaryResult CanGreetAsync() + => this.core.CanGreetAsync.InvokeUnary(this, "IGreeterService/CanGreetAsync", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new GreeterServiceClient(options, core); - - public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) - => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); - public global::MagicOnion.UnaryResult PingAsync() - => this.core.PingAsync.InvokeUnaryNonGeneric(this, "IGreeterService/PingAsync", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult CanGreetAsync() - => this.core.CanGreetAsync.InvokeUnary(this, "IGreeterService/CanGreetAsync", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index 0ffa2328e..aa72737d8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace MyApplication1 partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs index 3327da194..c05207373 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MyApplication1.GreeterServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyApplication1_GreeterServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index eea855741..7479234db 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs index 74314a900..d08cdccc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -64,7 +62,7 @@ static MagicOnionClientFactoryCache() if (typeof(T) == typeof(global::TempProject.IMyService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new TempProject.MyServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.TempProject_MyServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs index 8c6701050..ea461762e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs @@ -11,35 +11,40 @@ namespace TempProject using global::MagicOnion.Client; using global::MessagePack; - [global::MagicOnion.Ignore] - public class MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService + partial class MagicOnionInitializer { - class ClientCore + static partial class MagicOnionGeneratedClient { - public global::MagicOnion.Client.Internal.RawMethodInvoker A; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + [global::MagicOnion.Ignore] + public class TempProject_MyServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::TempProject.IMyService { - this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker A; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.A = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IMyService", "A", serializerProvider); + } + } + + readonly ClientCore core; + + public TempProject_MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new TempProject_MyServiceClient(options, core); + + public global::MagicOnion.UnaryResult A() + => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } } - - readonly ClientCore core; - - public MyServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyServiceClient(options, core); - - public global::MagicOnion.UnaryResult A() - => this.core.A.InvokeUnary(this, "IMyService/A", global::MessagePack.Nil.Default); } } - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index eea855741..7479234db 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs index 390875c8b..9c464304a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -76,7 +74,7 @@ static StreamingHubClientFactoryCache() if (typeof(TStreamingHub) == typeof(global::TempProject.IMyHub) && typeof(TReceiver) == typeof(global::TempProject.IMyHubReceiver)) { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new TempProject.MyHubClient(a, b, c, d, e))); + factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.TempProject_MyHubClient(a, b, c, d, e))); } Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0003_TempProject_MyHubClient.g.cs index ce0e1ffe9..152763a69 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0003_TempProject_MyHubClient.g.cs @@ -11,65 +11,70 @@ namespace TempProject using global::MagicOnion; using global::MagicOnion.Client; using global::MessagePack; - - [global::MagicOnion.Ignore] - public class MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub + + partial class MagicOnionInitializer { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task A(global::System.Int32 a) - => base.WriteMessageWithResponseAsync(-1005848884, a); - - public global::TempProject.IMyHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::TempProject.IMyHub + static partial class MagicOnionGeneratedClient { - readonly MyHubClient parent; - - public FireAndForgetClient(MyHubClient parent) - => this.parent = parent; - - public global::TempProject.IMyHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task A(global::System.Int32 a) - => parent.WriteMessageFireAndForgetAsync(-1005848884, a); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) + [global::MagicOnion.Ignore] + public class TempProject_MyHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::TempProject.IMyHub { - case -1262822265: // Void OnMessage(global::System.Int32 a) + protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } + + public TempProject_MyHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) + : base(callInvoker, host, options, serializerProvider, logger) + { + var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; + DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IMyHub", "Connect", marshaller, marshaller); + } + + public global::System.Threading.Tasks.Task A(global::System.Int32 a) + => base.WriteMessageWithResponseAsync(-1005848884, a); + + public global::TempProject.IMyHub FireAndForget() + => new FireAndForgetClient(this); + + [global::MagicOnion.Ignore] + class FireAndForgetClient : global::TempProject.IMyHub + { + readonly TempProject_MyHubClient parent; + + public FireAndForgetClient(TempProject_MyHubClient parent) + => this.parent = parent; + + public global::TempProject.IMyHub FireAndForget() => this; + public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); + public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); + + public global::System.Threading.Tasks.Task A(global::System.Int32 a) + => parent.WriteMessageFireAndForgetAsync(-1005848884, a); + + } + + protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) + { + switch (methodId) { - var value = base.Deserialize(data); - receiver.OnMessage(value); + case -1262822265: // Void OnMessage(global::System.Int32 a) + { + var value = base.Deserialize(data); + receiver.OnMessage(value); + } + break; } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -1005848884: // Task A(global::System.Int32 a) - base.SetResultForResponse(taskCompletionSource, data); - break; + } + + protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) + { + switch (methodId) + { + case -1005848884: // Task A(global::System.Int32 a) + base.SetResultForResponse(taskCompletionSource, data); + break; + } + } + } } - } } - diff --git a/tests/MagicOnion.Integration.Tests/ClientFilterTest.cs b/tests/MagicOnion.Integration.Tests/ClientFilterTest.cs index 8b9c69d18..6df9e70a7 100644 --- a/tests/MagicOnion.Integration.Tests/ClientFilterTest.cs +++ b/tests/MagicOnion.Integration.Tests/ClientFilterTest.cs @@ -5,8 +5,6 @@ using Xunit.Abstractions; using System.Diagnostics; using Grpc.Net.Client; -using MagicOnion.Integration.Tests.Generated; -using MagicOnion.Serialization; namespace MagicOnion.Integration.Tests; @@ -24,7 +22,7 @@ public ClientFilterTest(ITestOutputHelper logger, MagicOnionApplicationFactory EnumerateMagicOnionClientFactory() { yield return new [] { new TestMagicOnionClientFactory("Dynamic", DynamicMagicOnionClientFactoryProvider.Instance) }; - yield return new [] { new TestMagicOnionClientFactory("Generated", MagicOnionGeneratedClientFactoryProvider.Instance) }; + yield return new [] { new TestMagicOnionClientFactory("Generated", MagicOnionGeneratedClientInitializer.ClientFactoryProvider) }; } [Theory] diff --git a/tests/MagicOnion.Integration.Tests/DynamicArgumentTupleTest.cs b/tests/MagicOnion.Integration.Tests/DynamicArgumentTupleTest.cs index 9b4d973ae..097158a4b 100644 --- a/tests/MagicOnion.Integration.Tests/DynamicArgumentTupleTest.cs +++ b/tests/MagicOnion.Integration.Tests/DynamicArgumentTupleTest.cs @@ -1,9 +1,6 @@ using MagicOnion.Client; using Grpc.Net.Client; using MagicOnion.Server; -using Xunit.Abstractions; -using MagicOnion.Serialization; -using MagicOnion.Integration.Tests.Generated; namespace MagicOnion.Integration.Tests; @@ -19,7 +16,7 @@ public DynamicArgumentTupleServiceTest(MagicOnionApplicationFactory EnumerateMagicOnionClientFactory() { yield return new [] { new TestMagicOnionClientFactory("Dynamic", DynamicMagicOnionClientFactoryProvider.Instance) }; - yield return new [] { new TestMagicOnionClientFactory("Generated", MagicOnionGeneratedClientFactoryProvider.Instance) }; + yield return new [] { new TestMagicOnionClientFactory("Generated", MagicOnionGeneratedClientInitializer.ClientFactoryProvider) }; } [Theory] diff --git a/tests/MagicOnion.Integration.Tests/MagicOnionClientGeneratorOptions.json b/tests/MagicOnion.Integration.Tests/MagicOnionClientGeneratorOptions.json deleted file mode 100644 index d19e4c91f..000000000 --- a/tests/MagicOnion.Integration.Tests/MagicOnionClientGeneratorOptions.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "$schema": "../../MagicOnionClientGeneratorOptions.schema.json", - "disableAutoRegister": true, - "namespace": "MagicOnion.Integration.Tests.Generated" -} diff --git a/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs b/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs index 681608ddf..b9f83f598 100644 --- a/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs +++ b/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs @@ -2,6 +2,6 @@ namespace MagicOnion.Integration.Tests; -[MagicOnionClientGeneration(typeof(MagicOnionGeneratedClientInitializer))] +[MagicOnionClientGeneration(typeof(MagicOnionGeneratedClientInitializer), DisableAutoRegister = true)] public partial class MagicOnionGeneratedClientInitializer {} diff --git a/tests/MagicOnion.Integration.Tests/SerializerStreamingHubTest.cs b/tests/MagicOnion.Integration.Tests/SerializerStreamingHubTest.cs index c6de8da94..091075344 100644 --- a/tests/MagicOnion.Integration.Tests/SerializerStreamingHubTest.cs +++ b/tests/MagicOnion.Integration.Tests/SerializerStreamingHubTest.cs @@ -1,7 +1,5 @@ using Grpc.Net.Client; using MagicOnion.Client; -using MagicOnion.Integration.Tests.Generated; -using MagicOnion.Serialization; using MagicOnion.Server.Hubs; using MagicOnionTestServer; using Microsoft.AspNetCore.Mvc.Testing; @@ -23,7 +21,7 @@ public SerializerStreamingHubTest(MagicOnionApplicationFactory EnumerateStreamingHubClientFactory() { yield return new [] { new TestStreamingHubClientFactory("Dynamic", DynamicStreamingHubClientFactoryProvider.Instance) }; - yield return new [] { new TestStreamingHubClientFactory("Static", MagicOnionGeneratedClientFactoryProvider.Instance)}; + yield return new [] { new TestStreamingHubClientFactory("Static", MagicOnionGeneratedClientInitializer.StreamingHubClientFactoryProvider)}; } [Theory] @@ -41,7 +39,7 @@ public async Task StreamingHub_Parameterless(TestStreamingHubClientFactory clien // Assert result.Should().Be(123); } - + [Theory] [MemberData(nameof(EnumerateStreamingHubClientFactory))] public async Task StreamingHub_Parameter_One(TestStreamingHubClientFactory clientFactory) diff --git a/tests/MagicOnion.Integration.Tests/SerializerUnaryTest.cs b/tests/MagicOnion.Integration.Tests/SerializerUnaryTest.cs index baccb49d9..d15e6c6d9 100644 --- a/tests/MagicOnion.Integration.Tests/SerializerUnaryTest.cs +++ b/tests/MagicOnion.Integration.Tests/SerializerUnaryTest.cs @@ -1,6 +1,5 @@ using Grpc.Net.Client; using MagicOnion.Client; -using MagicOnion.Integration.Tests.Generated; using MagicOnion.Serialization; using MagicOnion.Server; using MagicOnionTestServer; @@ -21,11 +20,11 @@ public SerializerUnaryTest(MagicOnionApplicationFactory f x.MessageSerializer = XorMessagePackMagicOnionSerializerProvider.Instance; }); } - + public static IEnumerable EnumerateMagicOnionClientFactory() { yield return new [] { new TestMagicOnionClientFactory("Dynamic", DynamicMagicOnionClientFactoryProvider.Instance) }; - yield return new [] { new TestMagicOnionClientFactory("Generated", MagicOnionGeneratedClientFactoryProvider.Instance) }; + yield return new [] { new TestMagicOnionClientFactory("Generated", MagicOnionGeneratedClientInitializer.ClientFactoryProvider) }; } [Theory] diff --git a/tests/MagicOnion.Integration.Tests/StreamingHubTest.cs b/tests/MagicOnion.Integration.Tests/StreamingHubTest.cs index a1e620d3f..5bf535a3f 100644 --- a/tests/MagicOnion.Integration.Tests/StreamingHubTest.cs +++ b/tests/MagicOnion.Integration.Tests/StreamingHubTest.cs @@ -1,9 +1,6 @@ -using System.Collections.Concurrent; using System.Diagnostics; using Grpc.Net.Client; using MagicOnion.Client; -using MagicOnion.Integration.Tests.Generated; -using MagicOnion.Serialization; using MagicOnion.Server; using MagicOnion.Server.Hubs; using Microsoft.Extensions.DependencyInjection; @@ -22,7 +19,7 @@ public StreamingHubTest(MagicOnionApplicationFactory factor public static IEnumerable EnumerateStreamingHubClientFactory() { yield return new [] { new TestStreamingHubClientFactory("Dynamic", DynamicStreamingHubClientFactoryProvider.Instance) }; - yield return new [] { new TestStreamingHubClientFactory("Static", MagicOnionGeneratedClientFactoryProvider.Instance)}; + yield return new [] { new TestStreamingHubClientFactory("Static", MagicOnionGeneratedClientInitializer.StreamingHubClientFactoryProvider)}; } [Theory] @@ -55,7 +52,7 @@ public async Task NoReturn_Parameter_One(TestStreamingHubClientFactory clientFac await client.NoReturn_Parameter_One(12345); } - + [Theory] [MemberData(nameof(EnumerateStreamingHubClientFactory))] public async Task NoReturn_Parameter_Many(TestStreamingHubClientFactory clientFactory) @@ -70,7 +67,7 @@ public async Task NoReturn_Parameter_Many(TestStreamingHubClientFactory clientFa // Act & Assert await client.NoReturn_Parameter_Many(12345, "Hello✨", true); } - + [Theory] [MemberData(nameof(EnumerateStreamingHubClientFactory))] public async Task Parameter_Zero(TestStreamingHubClientFactory clientFactory) @@ -155,7 +152,7 @@ public async Task ValueTask_NoReturn_Parameter_One(TestStreamingHubClientFactory await client.ValueTask_NoReturn_Parameter_One(12345); } - + [Theory] [MemberData(nameof(EnumerateStreamingHubClientFactory))] public async Task ValueTask_NoReturn_Parameter_Many(TestStreamingHubClientFactory clientFactory) @@ -170,7 +167,7 @@ public async Task ValueTask_NoReturn_Parameter_Many(TestStreamingHubClientFactor // Act & Assert await client.ValueTask_NoReturn_Parameter_Many(12345, "Hello✨", true); } - + [Theory] [MemberData(nameof(EnumerateStreamingHubClientFactory))] public async Task ValueTask_Parameter_Zero(TestStreamingHubClientFactory clientFactory) @@ -576,12 +573,12 @@ public Task Never() { return new TaskCompletionSource().Task.WaitAsync(TimeSpan.FromMilliseconds(100)); } - + public Task Never_With_Return() { return new TaskCompletionSource().Task.WaitAsync(TimeSpan.FromMilliseconds(100)); } - + public ValueTask ValueTask_NoReturn_Parameter_Zero() { return default; @@ -624,7 +621,7 @@ public ValueTask ValueTask_Never() { return new ValueTask(new TaskCompletionSource().Task.WaitAsync(TimeSpan.FromMilliseconds(100))); } - + public ValueTask ValueTask_Never_With_Return() { return new ValueTask(new TaskCompletionSource().Task.WaitAsync(TimeSpan.FromMilliseconds(100))); diff --git a/tests/MagicOnion.Integration.Tests/StreamingServiceTest.cs b/tests/MagicOnion.Integration.Tests/StreamingServiceTest.cs index 22bd6d416..ca3315f00 100644 --- a/tests/MagicOnion.Integration.Tests/StreamingServiceTest.cs +++ b/tests/MagicOnion.Integration.Tests/StreamingServiceTest.cs @@ -6,10 +6,7 @@ using System.Text; using System.Threading.Tasks; using MagicOnion.Client; -using MagicOnion.Integration.Tests.Generated; using MagicOnion.Server; -using MagicOnion.Serialization; -using Google.Protobuf.WellKnownTypes; namespace MagicOnion.Integration.Tests; @@ -25,7 +22,7 @@ public StreamingServiceTest(MagicOnionApplicationFactory f public static IEnumerable EnumerateMagicOnionClientFactory() { yield return new [] { new TestMagicOnionClientFactory("Dynamic", DynamicMagicOnionClientFactoryProvider.Instance) }; - yield return new [] { new TestMagicOnionClientFactory("Generated", MagicOnionGeneratedClientFactoryProvider.Instance) }; + yield return new [] { new TestMagicOnionClientFactory("Generated", MagicOnionGeneratedClientInitializer.ClientFactoryProvider) }; } [Theory] @@ -161,7 +158,7 @@ public async Task DuplexStreamingRefType_1(TestMagicOnionClientFactory clientFac // Assert sum.Should().Be(123 + 456 + 789 + 123 + 111 + 222); } - + [Theory] [MemberData(nameof(EnumerateMagicOnionClientFactory))] public async Task ClientStreamingRefType_RequestResponseNull(TestMagicOnionClientFactory clientFactory) @@ -339,7 +336,7 @@ public async Task return context.Result(); } - + public async Task> ClientStreamingRefTypeReturnsNull() { await Task.Yield(); diff --git a/tests/MagicOnion.Integration.Tests/UnaryServiceTest.cs b/tests/MagicOnion.Integration.Tests/UnaryServiceTest.cs index 4b8e1116a..88464510b 100644 --- a/tests/MagicOnion.Integration.Tests/UnaryServiceTest.cs +++ b/tests/MagicOnion.Integration.Tests/UnaryServiceTest.cs @@ -1,14 +1,7 @@ using Grpc.Net.Client; -using MagicOnion.Serialization; -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using MagicOnion.Client; using MagicOnion.Server; -using MagicOnion.Integration.Tests.Generated; namespace MagicOnion.Integration.Tests; @@ -24,7 +17,7 @@ public UnaryServiceTest(MagicOnionApplicationFactory factory) public static IEnumerable EnumerateMagicOnionClientFactory() { yield return new [] { new TestMagicOnionClientFactory("Dynamic", DynamicMagicOnionClientFactoryProvider.Instance) }; - yield return new [] { new TestMagicOnionClientFactory("Generated", MagicOnionGeneratedClientFactoryProvider.Instance) }; + yield return new [] { new TestMagicOnionClientFactory("Generated", MagicOnionGeneratedClientInitializer.ClientFactoryProvider) }; } [Theory] From fbbca96836f5bbace9991dd78c18cd1be10a6d39 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 17:00:56 +0900 Subject: [PATCH 37/66] Remove System.Text.Json dependency --- MagicOnionClientGeneratorOptions.schema.json | 26 ------ ...cOnion.Client.SourceGenerator.Unity.csproj | 3 +- ...MagicOnionClientSourceGenerator.Roslyn3.cs | 1 - .../CodeGen/MagicOnionInitializerGenerator.cs | 12 +-- .../StaticMagicOnionClientGenerator.cs | 2 +- .../GenerationContext.cs | 48 +++++++++++ .../GeneratorOptions.cs | 73 ---------------- .../MagicOnion.Client.SourceGenerator.csproj | 1 - .../MagicOnion.Client.SourceGenerator.targets | 5 -- .../MagicOnionClientGenerator.cs | 23 ++--- .../MagicOnionClientSourceGenerator.Emit.cs | 29 +++++-- .../MagicOnionClientSourceGenerator.cs | 26 +++--- .../GeneratorOptionsTest.cs | 48 +++++------ ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0004_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0004_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0004_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0004_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0004_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0004_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0004_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...003_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0004_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...1_MyApplication1_GreeterServiceClient.g.cs | 2 +- ..._MyApplication1_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...on1_Net_Remoting_GreeterServiceClient.g.cs | 2 +- ...n1_Net_Remoting_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...006_MyNamespace_MagicOnionInitializer.g.cs | 2 +- .../0007_MyNamespace_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...1_MyApplication1_GreeterServiceClient.g.cs | 2 +- ..._MyApplication1_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- .../0003_TempProject_MyServiceClient.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...002_TempProject_MagicOnionInitializer.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...1_MyApplication1_GreeterServiceClient.g.cs | 50 +++++++++++ ...tion1_MagicOnionInitializer_Resolver.g.cs} | 6 +- ...MyApplication1_MagicOnionInitializer.g.cs} | 20 ++--- ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ----- ...cOnionClientSourceGeneratorAttributes.g.cs | 42 +++++++++ ...1_MyApplication1_GreeterServiceClient.g.cs | 50 +++++++++++ ...ation1_MagicOnionInitializer_Resolver.g.cs | 76 +++++++++++++++++ ..._MyApplication1_MagicOnionInitializer.g.cs | 79 +++++++++++++++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- .../0001__MagicOnionInitializer_Resolver.g.cs | 76 +++++++++++++++++ .../0002__MagicOnionInitializer.g.cs | 82 ++++++++++++++++++ ...3_MyApplication1_GreeterServiceClient.g.cs | 47 ++++++++++ ...cOnionClientSourceGeneratorAttributes.g.cs | 23 ----- ...cOnionClientSourceGeneratorAttributes.g.cs | 25 +++++- ...1_MyApplication1_GreeterServiceClient.g.cs | 50 +++++++++++ ...ation1_MagicOnionInitializer_Resolver.g.cs | 76 +++++++++++++++++ ..._MyApplication1_MagicOnionInitializer.g.cs | 85 +++++++++++++++++++ .../MagicOnionSourceGeneratorVerifier.cs | 11 +-- 232 files changed, 2859 insertions(+), 618 deletions(-) delete mode 100644 MagicOnionClientGeneratorOptions.schema.json create mode 100644 src/MagicOnion.Client.SourceGenerator/GenerationContext.cs delete mode 100644 src/MagicOnion.Client.SourceGenerator/GeneratorOptions.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0001_MyApplication1_GreeterServiceClient.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateTest/Generate_Namespace/0002_Remoting_MagicOnionInitializer_Resolver.g.cs => GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs} (90%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/{GenerateTest/Generate_Namespace/0003_Remoting_MagicOnionInitializer.g.cs => GeneratorOptionsTest/Default/0003_MyApplication1_MagicOnionInitializer.g.cs} (83%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/0000_MagicOnionClientSourceGeneratorAttributes.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0001_MyApplication1_GreeterServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0003_MyApplication1_MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0002__MagicOnionInitializer.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0003_MyApplication1_GreeterServiceClient.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0001_MyApplication1_GreeterServiceClient.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0003_MyApplication1_MagicOnionInitializer.g.cs diff --git a/MagicOnionClientGeneratorOptions.schema.json b/MagicOnionClientGeneratorOptions.schema.json deleted file mode 100644 index b483ca391..000000000 --- a/MagicOnionClientGeneratorOptions.schema.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "type": "object", - "properties": { - "disableAutoRegister": { - "description": "Disable automatically calling MagicOnionInitializer during start-up. (Automatic registration requires .NET 5+ or Unity)", - "type": "boolean" - }, - "namespace": { - "description": "The namespace of clients to generate.", - "type": "string" - }, - "messagePackFormatterNamespace": { - "description": "the namespace of pre-generated MessagePackFormatters.", - "type": "string" - }, - "serializer": { - "description": "The serializer used for message serialization.", - "type": "string", - "enum": [ - "MessagePack", - "MemoryPack" - ] - } - } -} \ No newline at end of file diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj index afdaca30b..c16514c78 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -20,7 +20,7 @@ - + @@ -31,6 +31,5 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs index 29d238d6c..ef38fb7ab 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs @@ -17,7 +17,6 @@ public void Initialize(GeneratorInitializationContext context) public void Execute(GeneratorExecutionContext context) { var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxReceiver!; - var options = GeneratorOptions.Create(context.AdditionalFiles, context.CancellationToken); if (ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) { var generationContext = new GenerationContext(null, "MagicOnionInitializer", new SourceProductionContext(context)); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs index f40609bdc..f7e93a977 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs @@ -5,7 +5,7 @@ namespace MagicOnion.Client.SourceGenerator.CodeGen; internal class MagicOnionInitializerGenerator { - public static string Build(string? @namespace, string typeName, GeneratorOptions options, MagicOnionServiceCollection serviceCollection) + public static string Build(GenerationContext generationContext, MagicOnionServiceCollection serviceCollection) { var writer = new StringWriter(); writer.WriteLine($$""" @@ -14,10 +14,10 @@ public static string Build(string? @namespace, string typeName, GeneratorOptions #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. """); - if (!string.IsNullOrEmpty(@namespace)) + if (!string.IsNullOrEmpty(generationContext.Namespace)) { writer.WriteLine($$""" - namespace {{@namespace}} + namespace {{generationContext.Namespace}} { """); } @@ -31,7 +31,7 @@ namespace {{@namespace}} partial class PreserveAttribute : global::System.Attribute {} - partial class {{typeName}} + partial class {{generationContext.InitializerPartialTypeName}} { static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); @@ -40,7 +40,7 @@ partial class {{typeName}} public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; """); - if (!options.DisableAutoRegister) + if (!generationContext.Options.DisableAutoRegistration) { writer.WriteLine($$""" #if UNITY_2019_4_OR_NEWER @@ -131,7 +131,7 @@ static StreamingHubClientFactoryCache() } } """); - if (!string.IsNullOrEmpty(@namespace)) + if (!string.IsNullOrEmpty(generationContext.Namespace)) { writer.WriteLine($$""" } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs index fd68cacd2..a0ca2e0ac 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs @@ -119,7 +119,7 @@ public class {{ctx.Service.GetClientFullName()}} : global::MagicOnion.Client.Mag static void EmitClone(ServiceClientBuildContext ctx) { ctx.TextWriter.WriteLine($""" - protected override global::MagicOnion.Client.MagicOnionClientBase<{ctx.Service.ServiceType.Name}> Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase<{ctx.Service.ServiceType.FullName}> Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new {ctx.Service.GetClientFullName()}(options, core); """); ctx.TextWriter.WriteLine(); diff --git a/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs b/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs new file mode 100644 index 000000000..a55f97a4a --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs @@ -0,0 +1,48 @@ +using Microsoft.CodeAnalysis; + +namespace MagicOnion.Client.SourceGenerator; + +public readonly record struct GenerationContext( + string? Namespace, + string InitializerPartialTypeName, + SourceProductionContext SourceProductionContext, + GenerationOptions Options +); + + +// This enum must be mirror of generated `SerializerType` (MagicOnionClientSourceGenerator.Emit) +public enum SerializerType +{ + MessagePack = 0, + MemoryPack = 1, +} + +public record GenerationOptions(SerializerType Serializer, bool DisableAutoRegistration, string MessagePackFormatterNamespace) +{ + public static GenerationOptions Default { get; } = new GenerationOptions(SerializerType.MessagePack, false, "MessagePack.Formatters"); + + public static GenerationOptions Parse(AttributeData attr) + { + var options = GenerationOptions.Default; + + foreach (var namedArg in attr.NamedArguments) + { + if (namedArg.Value.Kind is TypedConstantKind.Error or not TypedConstantKind.Primitive) continue; + + switch (namedArg.Key) + { + case nameof(GenerationOptions.DisableAutoRegistration): + options = options with { DisableAutoRegistration = (bool)namedArg.Value.Value! }; + break; + case nameof(GenerationOptions.Serializer): + options = options with { Serializer = (SerializerType)(int)namedArg.Value.Value! }; + break; + case nameof(GenerationOptions.MessagePackFormatterNamespace): + options = options with { MessagePackFormatterNamespace = (string)namedArg.Value.Value! }; + break; + } + } + + return options; + } +} diff --git a/src/MagicOnion.Client.SourceGenerator/GeneratorOptions.cs b/src/MagicOnion.Client.SourceGenerator/GeneratorOptions.cs deleted file mode 100644 index bc5a193bb..000000000 --- a/src/MagicOnion.Client.SourceGenerator/GeneratorOptions.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System.Collections.Immutable; -using System.Text.Json; -using Microsoft.CodeAnalysis; - -namespace MagicOnion.Client.SourceGenerator; - -/* -[Option("u", "Do not use UnityEngine's RuntimeInitializeOnLoadMethodAttribute on MagicOnionInitializer. (Same as --disable-auto-register)")]bool noUseUnityAttr = false, -[Option("d", "Do not automatically call MagicOnionInitializer during start-up. (Automatic registration requires .NET 5+ or Unity)")]bool disableAutoRegister = false, -[Option("n", "The namespace of clients to generate.")]string @namespace = "MagicOnion", -[Option("m", "The namespace of pre-generated MessagePackFormatters.")]string messagepackFormatterNamespace = "MessagePack.Formatters", -[Option("s", "The serializer used for message serialization")] SerializerType serializer = SerializerType.MessagePack -*/ - -public record GeneratorOptions -{ - public const string JsonFileName = "MagicOnionClientGeneratorOptions.json"; - - static readonly JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions() - { - AllowTrailingCommas = true, - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - ReadCommentHandling = JsonCommentHandling.Skip, - }; - - public static GeneratorOptions Default { get; } = new GeneratorOptions(); - - /// - /// Gets or sets whether to disable automatically calling MagicOnionInitializer during start-up. (Automatic registration requires .NET 5+ or Unity) - /// - public bool DisableAutoRegister { get; init; } - - /// - /// Gets or sets the namespace of clients to generate. The default value is MagicOnion. - /// - public string Namespace { get; init; } = "MagicOnion"; - - /// - /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. - /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; - - /// - /// Gets or set the serializer used for message serialization. The default value is . - /// - public SerializerType Serializer { get; init; } = SerializerType.MessagePack; - - public enum SerializerType - { - MessagePack, - MemoryPack - } - - public static GeneratorOptions Create(ImmutableArray additionalTexts, CancellationToken cancellationToken) - { - var options = Default; - - var optionsJsonFile = additionalTexts.FirstOrDefault(x => string.Equals(Path.GetFileName(x.Path), JsonFileName, StringComparison.InvariantCultureIgnoreCase)); - if (optionsJsonFile != null) - { - var content = optionsJsonFile.GetText(cancellationToken)?.ToString(); - if (content != null) - { - options = JsonSerializer.Deserialize(content, jsonSerializerOptions) ?? Default; - } - } - - return options; - } - - public string ToJson() - => JsonSerializer.Serialize(this, jsonSerializerOptions); -} diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index 079ae98fe..5aac9156f 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -20,7 +20,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets index f5dbb6db6..d9a67a6ac 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets @@ -3,11 +3,6 @@ - diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs index b6ab6b473..49c661a32 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs @@ -10,26 +10,17 @@ public static class MagicOnionClientGenerator { var outputs = new List<(string Path, string Source)>(); - var options = GeneratorOptions.Default; - - // . - var namespaceDot = string.IsNullOrWhiteSpace(options.Namespace) ? string.Empty : options.Namespace + "."; - // .Formatters - var formattersNamespace = namespaceDot + "Formatters"; - // Configure serialization - (ISerializationFormatterNameMapper Mapper, string Namespace, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) - serialization = options.Serializer switch + (ISerializationFormatterNameMapper Mapper, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) + serialization = context.Options.Serializer switch { - GeneratorOptions.SerializerType.MemoryPack => ( + SerializerType.MemoryPack => ( Mapper: new MemoryPackFormatterNameMapper(), - Namespace: options.Namespace, Generator: new MemoryPackFormatterRegistrationGenerator(), EnumFormatterGenerator: _ => string.Empty ), - GeneratorOptions.SerializerType.MessagePack => ( - Mapper: new MessagePackFormatterNameMapper(options.MessagePackFormatterNamespace), - Namespace: namespaceDot + "Resolvers", + SerializerType.MessagePack => ( + Mapper: new MessagePackFormatterNameMapper(context.Options.MessagePackFormatterNamespace), Generator: new MessagePackFormatterResolverGenerator(), EnumFormatterGenerator: x => MessagePackEnumFormatterGenerator.Build(context, x) ), @@ -43,12 +34,12 @@ public static class MagicOnionClientGenerator cancellationToken.ThrowIfCancellationRequested(); - var formatterCodeGenContext = new SerializationFormatterCodeGenContext(formattersNamespace, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); + var formatterCodeGenContext = new SerializationFormatterCodeGenContext(context.Namespace ?? string.Empty, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); var resolverTexts = serialization.Generator.Build(context, formatterCodeGenContext); cancellationToken.ThrowIfCancellationRequested(); - outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName), MagicOnionInitializerGenerator.Build(context.Namespace, context.InitializerPartialTypeName, options, serviceCollection))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName), MagicOnionInitializerGenerator.Build(context, serviceCollection))); outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".Resolver"), resolverTexts)); foreach (var enumSerializationInfo in serializationInfoCollection.Enums) diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs index 64a788260..431b5605c 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs @@ -4,8 +4,6 @@ namespace MagicOnion.Client.SourceGenerator; -public readonly record struct GenerationContext(string? Namespace, string InitializerPartialTypeName, SourceProductionContext SourceProductionContext); - public partial class MagicOnionClientSourceGenerator { public const string SourceGeneratorAttributesHintName = "MagicOnionClientSourceGeneratorAttributes.g.cs"; @@ -18,24 +16,43 @@ static void AddAttributeSources(Action addSource) // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class {{MagicOnionClientGenerationAttributeName}} : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; - public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + /// Types contained in the scan target assembly public {{MagicOnionClientGenerationAttributeName}}(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } """); diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index b4d84c322..d0a357f1a 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -26,20 +26,20 @@ public void Initialize(IncrementalGeneratorInitializationContext context) if (referenceSymbols is null) return; // TODO: ReportDiagnostic var interfaceSymbols = new List(); - foreach (var attr in attrs) - { - // If the constructor has errors in the arguments, the first argument may be `Type` instead of `Array`. We need `Array` to proceed. - if (attr.ConstructorArguments[0].Kind != TypedConstantKind.Array) continue; + var attr = attrs.FirstOrDefault(x => x.AttributeClass?.Name == MagicOnionClientGenerationAttributeName); + if (attr is null) return; // TODO: ReportDiagnostic + + // If the constructor has errors in the arguments, the first argument may be `Type` instead of `Array`. We need `Array` to proceed. + if (attr.ConstructorArguments[0].Kind != TypedConstantKind.Array) return; // TODO: ReportDiagnostic - foreach (var typeContainedInTargetAssembly in attr.ConstructorArguments[0].Values) // Type[] typesContainedInTargetAssembly + foreach (var typeContainedInTargetAssembly in attr.ConstructorArguments[0].Values) // Type[] typesContainedInTargetAssembly + { + if (typeContainedInTargetAssembly.Value is INamedTypeSymbol typeSymbolContainedInTargetAssembly) { - if (typeContainedInTargetAssembly.Value is INamedTypeSymbol typeSymbolContainedInTargetAssembly) - { - var scanTargetAssembly = typeSymbolContainedInTargetAssembly.ContainingAssembly; - if (scanTargetAssembly is null) continue; + var scanTargetAssembly = typeSymbolContainedInTargetAssembly.ContainingAssembly; + if (scanTargetAssembly is null) continue; - Traverse(scanTargetAssembly.GlobalNamespace, interfaceSymbols); - } + Traverse(scanTargetAssembly.GlobalNamespace, interfaceSymbols); } } @@ -53,7 +53,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context) : initializerClassSymbol.ContainingNamespace.ToDisplayString(); var initializerPartialTypeName = initializerClassSymbol.Name; - var generationContext = new GenerationContext(initializerPartialTypeNamespace, initializerPartialTypeName, sourceProductionContext); + var option = GenerationOptions.Parse(attr); + var generationContext = new GenerationContext(initializerPartialTypeNamespace, initializerPartialTypeName, sourceProductionContext, option); Generate(generationContext, interfaceSymbols.ToImmutableArray(), referenceSymbols); static void Traverse(INamespaceOrTypeSymbol rootNamespaceOrTypeSymbol, List interfaceSymbols) @@ -72,4 +73,5 @@ static void Traverse(INamespaceOrTypeSymbol rootNamespaceOrTypeSymbol, List { UnaryResult HelloAsync(string name, int age); } + + [MagicOnionClientGeneration(typeof(IGreeterService))] + partial class MagicOnionInitializer {} """; await MagicOnionSourceGeneratorVerifier.RunAsync(source); } [Fact] - public async Task DisableAutoRegister() + public async Task DisableAutoRegistration() { var source = """ using MagicOnion; - + using MagicOnion.Client; + namespace MyApplication1; public interface IGreeterService : IService { UnaryResult HelloAsync(string name, int age); } + + [MagicOnionClientGeneration(typeof(IGreeterService), DisableAutoRegistration = true)] + partial class MagicOnionInitializer {} """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source, options: GeneratorOptions.Default with { DisableAutoRegister = true }); + await MagicOnionSourceGeneratorVerifier.RunAsync(source); } - [Fact] - public async Task Namespace() - { - var source = """ - using MagicOnion; - - namespace MyApplication1; - - public interface IGreeterService : IService - { - UnaryResult HelloAsync(string name, int age); - } - """; - - await MagicOnionSourceGeneratorVerifier.RunAsync(source, options: GeneratorOptions.Default with { Namespace = "__Generated__" }); - } - [Fact] public async Task MessagePackFormatterNamespace() { var source = """ using System; using MagicOnion; - + using MagicOnion.Client; + namespace MyApplication1 { public interface IGreeterService : IService @@ -80,9 +72,12 @@ public class MyGenericObjectFormatter : global::MessagePack.Formatters.IMessa public global::MyApplication1.MyGenericObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) => throw new NotImplementedException(); } } + + [MagicOnionClientGeneration(typeof(MyApplication1.IGreeterService), MessagePackFormatterNamespace = "__UserDefined__.MessagePack.Formatters")] + partial class MagicOnionInitializer {} """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source, options: GeneratorOptions.Default with { MessagePackFormatterNamespace = "__UserDefined__.MessagePack.Formatters" }); + await MagicOnionSourceGeneratorVerifier.RunAsync(source); } [Fact] @@ -90,18 +85,21 @@ public async Task Serializer_MemoryPack() { var source = """ using MagicOnion; - + using MagicOnion.Client; + namespace MyApplication1; public interface IGreeterService : IService { UnaryResult HelloAsync(string name, int age); } + + [MagicOnionClientGeneration(typeof(IGreeterService), Serializer = GenerateSerializerType.MemoryPack)] + partial class MagicOnionInitializer {} """; await MagicOnionSourceGeneratorVerifier.RunAsync( source, - options: GeneratorOptions.Default with { Serializer = GeneratorOptions.SerializerType.MemoryPack }, verifierOptions: VerifierOptions.Default with { UseMemoryPack = true } ); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs index 73d7f6865..06ca180d0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0004_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetEnumAsync(global::System.Nullable a) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs index 716ddeb35..f146ca389 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0004_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetEnumAsync(global::TempProject.MyEnum a) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs index e2e327613..9775db605 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0004_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetEnumAsync(global::System.Nullable a) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs index 3e0cd5118..d2587ba31 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0004_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetEnumAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs index 6a45bfb98..b500350e4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0004_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult> GetEnumAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs index c23619b2f..2c4bc0718 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0003_TempProject_MyServiceClient.g.cs @@ -59,7 +59,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult> MethodList(global::System.Collections.Generic.List args) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs index 5c9013aee..4d320953c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0003_TempProject_MyServiceClient.g.cs @@ -43,7 +43,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult A(global::TempProject.MyGenericObject a) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index 563f427c1..159679144 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -47,7 +47,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetStringValuesAsync(global::System.String[] arg0) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index f630384e8..7a9748b57 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetValuesAsync(global::TempProject.MyResponse[] arg0) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index 3658dae21..e61b90869 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -41,7 +41,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetStringValuesAsync(global::System.Collections.Generic.List arg0) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index 923742ba3..488b0f732 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetValuesAsync(global::System.Collections.Generic.List arg0) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs index 5875ffdd9..a66603077 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0003_TempProject_MyServiceClient.g.cs @@ -43,7 +43,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult A(global::TempProject.MyGenericObject> a) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs index 55b53a323..dd1c41b8f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetValuesAsync(global::TempProject.MyGenericObject arg0) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs index ac1628b0a..1274db022 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0004_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetEnumAsync(global::TempProject.MyGenericObject> arg0) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs index c8c98a4d1..5415f183a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0003_TempProject_MyServiceClient.g.cs @@ -41,7 +41,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult> A() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index 66c75caa4..8cdfbe99f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -47,7 +47,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetStringValuesAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index 0dddf7e04..6cec66f30 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult GetValuesAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs index 76ebdd25c..7402d71ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0004_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult> GetEnumAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs index 079626789..c483af180 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0003_TempProject_MyServiceClient.g.cs @@ -41,7 +41,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult> GetStringValuesAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs index b4cb9cfaa..a30ea80d8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult> GetValuesAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs index 0ccfa3133..d8d7b0cc9 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0003_TempProject_MyServiceClient.g.cs @@ -41,7 +41,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult> A() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs index 65b42b07a..36c7f81ed 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0003_TempProject_MyServiceClient.g.cs @@ -43,7 +43,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult>> A() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs index 9ca5633f2..52b9bffc3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult> GetValuesAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs index 619f15603..b16722f25 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0004_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult>> GetEnumAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs index dbffc1b11..7b4348c39 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0003_TempProject_MyServiceClient.g.cs @@ -43,7 +43,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::System.Threading.Tasks.Task> ClientStreamingAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs index 2b2329640..d641e68ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index 2b2329640..d641e68ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs index 2b2329640..d641e68ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index 2b2329640..d641e68ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs index dbffc1b11..7b4348c39 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0003_TempProject_MyServiceClient.g.cs @@ -43,7 +43,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::System.Threading.Tasks.Task> ClientStreamingAsync() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs index c8aacfd1b..5b6f5d3c0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult A() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs index 093fda01d..6635b8c5c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult A() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs index ea461762e..49e73575d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult A() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs index d239a4cfc..f75e88038 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult A() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs index 2b2329640..d641e68ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs index 2b2329640..d641e68ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs index e59d8e942..5fba9d3a1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0001_MyApplication1_GreeterServiceClient.g.cs @@ -43,7 +43,7 @@ private MyApplication1_GreeterServiceClient(MagicOnionClientOptions options, Cli this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyApplication1_GreeterServiceClient(options, core); public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs index c05207373..dbde9de8e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0001_MyApplication1_Net_Remoting_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0001_MyApplication1_Net_Remoting_GreeterServiceClient.g.cs index 047ce82a1..a692cecb8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0001_MyApplication1_Net_Remoting_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0001_MyApplication1_Net_Remoting_GreeterServiceClient.g.cs @@ -43,7 +43,7 @@ private MyApplication1_Net_Remoting_GreeterServiceClient(MagicOnionClientOptions this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyApplication1_Net_Remoting_GreeterServiceClient(options, core); public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs index 52e4e4183..494723c73 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs index f9ff01e88..5962afe29 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs index 6a3318886..d76e271a9 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private MyNamespace_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyNamespace_MyServiceClient(options, core); public global::MagicOnion.UnaryResult A(global::System.Int32 arg0, global::System.Collections.Generic.IReadOnlyList arg1, global::System.IO.FileMode arg2, global::System.Linq.ILookup arg3, global::System.Net.Http.ClientCertificateOption arg4, global::System.Threading.ApartmentState arg5, global::System.Threading.Tasks.TaskCreationOptions arg6) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs index e59d8e942..5fba9d3a1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs @@ -43,7 +43,7 @@ private MyApplication1_GreeterServiceClient(MagicOnionClientOptions options, Cli this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new MyApplication1_GreeterServiceClient(options, core); public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs index c05207373..dbde9de8e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs index d08cdccc3..849877a9a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs index ea461762e..49e73575d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0003_TempProject_MyServiceClient.g.cs @@ -39,7 +39,7 @@ private TempProject_MyServiceClient(MagicOnionClientOptions options, ClientCore this.core = core; } - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new TempProject_MyServiceClient(options, core); public global::MagicOnion.UnaryResult A() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs index 9c464304a..bae44ef82 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs @@ -24,7 +24,7 @@ partial class MagicOnionInitializer #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); public static bool TryRegisterProviderFactory() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0001_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0001_MyApplication1_GreeterServiceClient.g.cs new file mode 100644 index 000000000..7765f5892 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0001_MyApplication1_GreeterServiceClient.g.cs @@ -0,0 +1,50 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyApplication1 +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static partial class MagicOnionGeneratedClient + { + [global::MagicOnion.Ignore] + public class MyApplication1_GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyApplication1_GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyApplication1_GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyApplication1_GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_Remoting_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs similarity index 90% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_Remoting_MagicOnionInitializer_Resolver.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index 79fe273ba..02c7b0550 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_Remoting_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -3,14 +3,14 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. -namespace Remoting +namespace MyApplication1 { using global::System; using global::MessagePack; partial class MagicOnionInitializer { - public global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); @@ -68,8 +68,6 @@ internal static class TypeHints internal static void Register() { _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); - _ = MessagePackGeneratedResolver.Instance.GetFormatter(); - _ = MessagePackGeneratedResolver.Instance.GetFormatter(); _ = MessagePackGeneratedResolver.Instance.GetFormatter(); _ = MessagePackGeneratedResolver.Instance.GetFormatter(); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_Remoting_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0003_MyApplication1_MagicOnionInitializer.g.cs similarity index 83% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_Remoting_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0003_MyApplication1_MagicOnionInitializer.g.cs index f5a8bc55d..dbde9de8e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_Remoting_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -2,7 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. -namespace Remoting +namespace MyApplication1 { using global::System; using global::System.Collections.Generic; @@ -14,21 +14,19 @@ partial class PreserveAttribute : global::System.Attribute {} partial class MagicOnionInitializer { - bool isRegistered = false; - readonly MagicOnionGeneratedClientFactoryProvider provider = new(); + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - public static MagicOnionInitializer Instance { get; } = new(); - - public global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER [global::System.Runtime.CompilerServices.ModuleInitializer] #endif - static void Register() => Instance.TryRegisterProviderFactory(); + internal static void Register() => TryRegisterProviderFactory(); - public bool TryRegisterProviderFactory() + public static bool TryRegisterProviderFactory() { if (isRegistered) return false; isRegistered = true; @@ -62,9 +60,9 @@ static MagicOnionClientFactoryCache() { object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - if (typeof(T) == typeof(global::MyApplication1.Net.Remoting.IGreeterService)) + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyApplication1_Net_Remoting_GreeterServiceClient(x, y))); + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyApplication1_GreeterServiceClient(x, y))); } Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/0000_MagicOnionClientSourceGeneratorAttributes.g.cs deleted file mode 100644 index 4a8c8c00d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegister/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -namespace MagicOnion.Client -{ - [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - internal class MagicOnionClientGenerationAttribute : global::System.Attribute - { - public bool DisableAutoRegister { get; init; } - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; - public global::System.Type[] TypesContainedInTargetAssembly { get; } - - public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) - { - TypesContainedInTargetAssembly = typesContainedInTargetAssembly; - } - } - - internal enum GenerateSerializerType - { - MessagePack, - MemoryPack - } -} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs new file mode 100644 index 000000000..1a6ef5995 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -0,0 +1,42 @@ +// +namespace MagicOnion.Client +{ + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class MagicOnionClientGenerationAttribute : global::System.Attribute + { + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + /// Types contained in the scan target assembly + public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } + + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) + internal enum GenerateSerializerType + { + MessagePack = 0, + MemoryPack = 1, + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0001_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0001_MyApplication1_GreeterServiceClient.g.cs new file mode 100644 index 000000000..7765f5892 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0001_MyApplication1_GreeterServiceClient.g.cs @@ -0,0 +1,50 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyApplication1 +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static partial class MagicOnionGeneratedClient + { + [global::MagicOnion.Ignore] + public class MyApplication1_GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyApplication1_GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyApplication1_GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyApplication1_GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..02c7b0550 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyApplication1 +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0003_MyApplication1_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..afb573424 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -0,0 +1,79 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace MyApplication1 +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + + public static bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyApplication1_GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..a0ec17832 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, + {typeof(global::MyApplication1.MyGenericObject), 1}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + case 1: return new global::__UserDefined__.MessagePack.Formatters.MyApplication1.MyGenericObjectFormatter(); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0002__MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0002__MagicOnionInitializer.g.cs new file mode 100644 index 000000000..faac112f0 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0002__MagicOnionInitializer.g.cs @@ -0,0 +1,82 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + internal static void Register() => TryRegisterProviderFactory(); + + public static bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyApplication1_GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0003_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0003_MyApplication1_GreeterServiceClient.g.cs new file mode 100644 index 000000000..77c36394a --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0003_MyApplication1_GreeterServiceClient.g.cs @@ -0,0 +1,47 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static partial class MagicOnionGeneratedClient + { + [global::MagicOnion.Ignore] + public class MyApplication1_GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::MyApplication1.MyGenericObject> HelloAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::MyApplication1.MyGenericObject>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyApplication1_GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyApplication1_GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyApplication1_GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult> HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + } + } + } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs deleted file mode 100644 index 4a8c8c00d..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -namespace MagicOnion.Client -{ - [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - internal class MagicOnionClientGenerationAttribute : global::System.Attribute - { - public bool DisableAutoRegister { get; init; } - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; - public global::System.Type[] TypesContainedInTargetAssembly { get; } - - public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) - { - TypesContainedInTargetAssembly = typesContainedInTargetAssembly; - } - } - - internal enum GenerateSerializerType - { - MessagePack, - MemoryPack - } -} \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 4a8c8c00d..1a6ef5995 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -1,23 +1,42 @@ // namespace MagicOnion.Client { + /// + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. + /// [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] internal class MagicOnionClientGenerationAttribute : global::System.Attribute { - public bool DisableAutoRegister { get; init; } + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; init; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public global::System.Type[] TypesContainedInTargetAssembly { get; } + /// Types contained in the scan target assembly public MagicOnionClientGenerationAttribute(params global::System.Type[] typesContainedInTargetAssembly) { TypesContainedInTargetAssembly = typesContainedInTargetAssembly; } } + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) internal enum GenerateSerializerType { - MessagePack, - MemoryPack + MessagePack = 0, + MemoryPack = 1, } } \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0001_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0001_MyApplication1_GreeterServiceClient.g.cs new file mode 100644 index 000000000..7765f5892 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0001_MyApplication1_GreeterServiceClient.g.cs @@ -0,0 +1,50 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyApplication1 +{ + using global::System; + using global::Grpc.Core; + using global::MagicOnion; + using global::MagicOnion.Client; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static partial class MagicOnionGeneratedClient + { + [global::MagicOnion.Ignore] + public class MyApplication1_GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService + { + class ClientCore + { + public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; + public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) + { + this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); + } + } + + readonly ClientCore core; + + public MyApplication1_GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) + { + this.core = new ClientCore(serializerProvider); + } + + private MyApplication1_GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) + { + this.core = core; + } + + protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) + => new MyApplication1_GreeterServiceClient(options, core); + + public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) + => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs new file mode 100644 index 000000000..02c7b0550 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -0,0 +1,76 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyApplication1 +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; + class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); + + MessagePackGeneratedResolver() {} + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + => FormatterCache.formatter; + + static class FormatterCache + { + public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; + + static FormatterCache() + { + var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + static class MessagePackGeneratedGetFormatterHelper + { + static readonly global::System.Collections.Generic.Dictionary lookup; + + static MessagePackGeneratedGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, + }; + } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); + default: return null; + } + } + } + /// Type hints for Ahead-of-Time compilation. + [Preserve] + internal static class TypeHints + { + [Preserve] + internal static void Register() + { + _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + _ = MessagePackGeneratedResolver.Instance.GetFormatter(); + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0003_MyApplication1_MagicOnionInitializer.g.cs new file mode 100644 index 000000000..dbde9de8e --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -0,0 +1,85 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. +namespace MyApplication1 +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::MagicOnion; + using global::MagicOnion.Client; + + partial class PreserveAttribute : global::System.Attribute {} + + partial class MagicOnionInitializer + { + static bool isRegistered = false; + readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + + public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; +#if UNITY_2019_4_OR_NEWER + [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER + [global::System.Runtime.CompilerServices.ModuleInitializer] +#endif + internal static void Register() => TryRegisterProviderFactory(); + + public static bool TryRegisterProviderFactory() + { + if (isRegistered) return false; + isRegistered = true; + + global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = + (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) + ? immutableMagicOnionClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); + + global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = + (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) + ? immutableStreamingHubClientFactoryProvider.Add(provider) + : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); + + return true; + } + + class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider + { + bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) + => (factory = MagicOnionClientFactoryCache.Factory) != null; + + bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) + => (factory = StreamingHubClientFactoryCache.Factory) != null; + + static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService + { + public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; + + static MagicOnionClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); + + if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) + { + factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyApplication1_GreeterServiceClient(x, y))); + } + Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; + } + } + + static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub + { + public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; + + static StreamingHubClientFactoryCache() + { + object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); + + + Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index 747f7afd6..6702b3f10 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -33,16 +33,16 @@ internal record VerifierOptions internal class MagicOnionSourceGeneratorVerifier { - public static async Task RunAsync(string testSourceCode, GeneratorOptions? options = null, VerifierOptions? verifierOptions = null, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) + public static async Task RunAsync(string testSourceCode, VerifierOptions? verifierOptions = null, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) { if (string.IsNullOrEmpty(testSourceCode)) throw new ArgumentNullException(nameof(testSourceCode)); if (string.IsNullOrEmpty(testFile)) throw new ArgumentNullException(nameof(testFile)); if (string.IsNullOrEmpty(testMethod)) throw new ArgumentNullException(nameof(testMethod)); - await RunAsync(new[] { ("Source.cs", testSourceCode) }, options, verifierOptions, testFile, testMethod); + await RunAsync(new[] { ("Source.cs", testSourceCode) }, verifierOptions, testFile, testMethod); } - public static async Task RunAsync(IEnumerable<(string Path, string Content)> testSourceCodes, GeneratorOptions? options = null, VerifierOptions? verifierOptions = null, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) + public static async Task RunAsync(IEnumerable<(string Path, string Content)> testSourceCodes, VerifierOptions? verifierOptions = null, [CallerFilePath]string? testFile = null, [CallerMemberName]string? testMethod = null) { if (testSourceCodes is null) throw new ArgumentNullException(nameof(testSourceCodes)); if (string.IsNullOrEmpty(testFile)) throw new ArgumentNullException(nameof(testFile)); @@ -55,11 +55,6 @@ public static async Task RunAsync(IEnumerable<(string Path, string Content)> tes }, }; - if (options is not null) - { - test.TestState.AdditionalFiles.Add((GeneratorOptions.JsonFileName, options.ToJson())); - } - if (verifierOptions is not null) { if (verifierOptions.ExpectedDiagnostics is not null) From cb18cc5d8753b18407f8e3887aa3f4483a9db5d8 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 17:27:05 +0900 Subject: [PATCH 38/66] Fix diagnostics --- .../CodeAnalysis/MethodCollector.cs | 10 ++++---- .../GenerateServiceTest.cs | 24 +++++++++---------- .../GenerateStreamingHubTest.cs | 8 +++---- .../MagicOnionGeneratedClientInitializer.cs | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index 32effe38d..98120e86a 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -115,7 +115,7 @@ static bool TryCreateHubMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceT methodInfo = null; diagnostic = Diagnostic.Create( MagicOnionDiagnosticDescriptors.StreamingHubUnsupportedMethodReturnType, - methodSymbol.Locations.FirstOrDefault(), methodSymbol.Locations, null, + methodSymbol.Locations.FirstOrDefault(), null, null, $"{interfaceType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)}.{methodSymbol.Name}", methodReturnType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.FullyQualified)); return false; } @@ -143,7 +143,7 @@ static bool TryCreateHubReceiverMethodInfoFromMethodSymbol(MagicOnionTypeInfo in methodInfo = null; diagnostic = Diagnostic.Create( MagicOnionDiagnosticDescriptors.StreamingHubUnsupportedReceiverMethodReturnType, - methodSymbol.Locations.FirstOrDefault(), methodSymbol.Locations, null, + methodSymbol.Locations.FirstOrDefault(), null, null, $"{receiverType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)}.{methodSymbol.Name}", methodReturnType.ToDisplayName(MagicOnionTypeInfo.DisplayNameFormat.Namespace)); return false; } @@ -252,7 +252,7 @@ static bool TryCreateServiceMethodInfoFromMethodSymbol(MagicOnionTypeInfo servic { diagnostic = Diagnostic.Create( MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType, - methodSymbol.Locations.FirstOrDefault(), methodSymbol.Locations, null, + methodSymbol.Locations.FirstOrDefault(), null, null, methodReturnType.FullName, $"{serviceType.FullName}.{methodSymbol.Name}"); serviceMethodInfo = null; return false; @@ -261,7 +261,7 @@ static bool TryCreateServiceMethodInfoFromMethodSymbol(MagicOnionTypeInfo servic { diagnostic = Diagnostic.Create( MagicOnionDiagnosticDescriptors.UnaryUnsupportedMethodReturnType, - methodSymbol.Locations.FirstOrDefault(), methodSymbol.Locations, null, + methodSymbol.Locations.FirstOrDefault(), null, null, responseType.FullName, $"{serviceType.FullName}.{methodSymbol.Name}"); serviceMethodInfo = null; return false; @@ -270,7 +270,7 @@ static bool TryCreateServiceMethodInfoFromMethodSymbol(MagicOnionTypeInfo servic { diagnostic = Diagnostic.Create( MagicOnionDiagnosticDescriptors.StreamingMethodMustHaveNoParameters, - methodSymbol.Locations.FirstOrDefault(), methodSymbol.Locations, null, + methodSymbol.Locations.FirstOrDefault(), null, null, $"{serviceType.FullName}.{methodSymbol.Name}"); serviceMethodInfo = null; return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs index 9f783f431..6d5fdaba6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateServiceTest.cs @@ -121,7 +121,7 @@ namespace TempProject { public interface IMyService : IService { - Task> A(); + Task> {|#0:A|}(); } [MagicOnionClientGeneration(typeof(IMyService))] @@ -132,7 +132,7 @@ partial class MagicOnionInitializer {} var verifierOptions = VerifierOptions.Default with { TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, - ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error)} + ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error).WithLocation(0)} }; await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); } @@ -178,7 +178,7 @@ namespace TempProject { public interface IMyService : IService { - int A(); + int {|#0:A|}(); } [MagicOnionClientGeneration(typeof(IMyService))] @@ -189,7 +189,7 @@ partial class MagicOnionInitializer {} var verifierOptions = VerifierOptions.Default with { TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, - ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error)} + ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error).WithLocation(0)} }; await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); } @@ -208,7 +208,7 @@ namespace TempProject { public interface IMyService : IService { - UnaryResult> A(); + UnaryResult> {|#0:A|}(); } [MagicOnionClientGeneration(typeof(IMyService))] @@ -219,7 +219,7 @@ partial class MagicOnionInitializer {} var verifierOptions = VerifierOptions.Default with { TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, - ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.UnaryUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error)} + ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.UnaryUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error).WithLocation(0)} }; await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); } @@ -238,9 +238,9 @@ namespace TempProject { public interface IMyService : IService { - ClientStreamingResult ClientStreamingAsync(); - ServerStreamingResult ServerStreamingAsync(); - DuplexStreamingResult DuplexStreamingAsync(); + ClientStreamingResult {|#0:ClientStreamingAsync|}(); + ServerStreamingResult {|#1:ServerStreamingAsync|}(); + DuplexStreamingResult {|#2:DuplexStreamingAsync|}(); } [MagicOnionClientGeneration(typeof(IMyService))] @@ -253,9 +253,9 @@ partial class MagicOnionInitializer {} TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, ExpectedDiagnostics = new[] { - new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error), - new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error), - new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error), + new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error).WithLocation(0), + new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error).WithLocation(1), + new DiagnosticResult(MagicOnionDiagnosticDescriptors.ServiceUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error).WithLocation(2), } }; await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs index 3e7c39b68..57761e220 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateStreamingHubTest.cs @@ -289,7 +289,7 @@ namespace TempProject public interface IMyHubReceiver { } public interface IMyHub : IStreamingHub { - void A(); + void {|#0:A|}(); } [MagicOnionClientGeneration(typeof(IMyHub))] @@ -302,7 +302,7 @@ partial class MagicOnionInitializer {} TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, ExpectedDiagnostics = new[] { - new DiagnosticResult(MagicOnionDiagnosticDescriptors.StreamingHubUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error), + new DiagnosticResult(MagicOnionDiagnosticDescriptors.StreamingHubUnsupportedMethodReturnType.Id, DiagnosticSeverity.Error).WithLocation(0), } }; await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); @@ -322,7 +322,7 @@ namespace TempProject { public interface IMyHubReceiver { - Task B(); + Task {|#0:B|}(); } public interface IMyHub : IStreamingHub { @@ -338,7 +338,7 @@ partial class MagicOnionInitializer {} TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, ExpectedDiagnostics = new[] { - new DiagnosticResult(MagicOnionDiagnosticDescriptors.StreamingHubUnsupportedReceiverMethodReturnType.Id, DiagnosticSeverity.Error), + new DiagnosticResult(MagicOnionDiagnosticDescriptors.StreamingHubUnsupportedReceiverMethodReturnType.Id, DiagnosticSeverity.Error).WithLocation(0), } }; await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions: verifierOptions); diff --git a/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs b/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs index b9f83f598..f24ea5fc8 100644 --- a/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs +++ b/tests/MagicOnion.Integration.Tests/MagicOnionGeneratedClientInitializer.cs @@ -2,6 +2,6 @@ namespace MagicOnion.Integration.Tests; -[MagicOnionClientGeneration(typeof(MagicOnionGeneratedClientInitializer), DisableAutoRegister = true)] +[MagicOnionClientGeneration(typeof(MagicOnionGeneratedClientInitializer), DisableAutoRegistration = true)] public partial class MagicOnionGeneratedClientInitializer {} From 7a838f34b093872464cbc21892609b3ffb278218 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 17:34:05 +0900 Subject: [PATCH 39/66] Fix --- .../CodeGen/MessagePackFormatterResolverGenerator.cs | 5 +++-- .../CodeGen/StaticStreamingHubClientGenerator.cs | 1 + .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../HubReceiver/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0004_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Parameters/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Parameters_Nested/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Return/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Return_Enum/0004_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Return_Nested/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Return_Nested_Array/0003_TempProject_MyHubClient.g.cs | 1 + .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Complex/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Parameter_Many/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Parameter_One/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Parameter_Zero/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Return_Task/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Return_TaskOfT/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Return_ValueTask/0003_TempProject_MyHubClient.g.cs | 1 + .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs | 1 + .../0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs | 3 ++- ...ication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0003_TempProject_MyHubClient.g.cs | 1 + .../0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0001__MagicOnionInitializer_Resolver.g.cs | 3 ++- .../0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs | 3 ++- tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs | 4 +++- .../Verifiers/MagicOnionSourceGeneratorVerifier.cs | 3 --- 131 files changed, 220 insertions(+), 92 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs index dcfb562ef..379d82ce1 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs @@ -20,7 +20,8 @@ static void EmitPreamble(GenerationContext generationContext, SerializationForma #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. - + #pragma warning disable CS1522 // Empty switch block + """); } @@ -149,7 +150,7 @@ static void EmitTypeHints(SerializationFormatterCodeGenContext ctx) ctx.TextWriter.WriteLine($$""" /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs index 62c7437fa..d5c11df28 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs @@ -47,6 +47,7 @@ static void EmitHeader(GenerationContext generationContext, IndentedTextWriter t #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. + #pragma warning disable CS1522 // Empty switch block """); } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index ddbcd27ae..a66075dd6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 3ee70a438..76d5c9a7f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 30d2aa060..624c513a6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 3ee70a438..76d5c9a7f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 30d2aa060..624c513a6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 563c6e0d8..364edd7ea 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0003_TempProject_MyHubClient.g.cs index 01d8b5837..ca9b6620c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 0d16a45ab..33c1c862a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index be91c6e71..d49f2fa23 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4a8cdd678..d5382352d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs index 1ae5aa565..f96c11f1f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 55eaace57..6c7b8ec6c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs index fe2616d09..8e20495d1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0004_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c184bcbe5..31efb2b9c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index 7059bdada..f2301ba6c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ce12962f..c0fe9bc08 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs index 5e8b6aa5d..f3329d20c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4e1919c85..d0d33bed1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs index 8aacb4324..49fc3ecdd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8c11aee07..f2c5d63ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -72,7 +73,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs index 54c0f38d6..c3b719ef4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4bac6483d..a50da026a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0003_TempProject_MyHubClient.g.cs index bc96a8e3f..17c57fea7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 29106145e..49fb95d42 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -66,7 +67,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0004_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0004_TempProject_MyHubClient.g.cs index 428ec682e..f02741256 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0004_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0004_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 563c6e0d8..364edd7ea 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0003_TempProject_MyHubClient.g.cs index e143d57ea..a44dbda0d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 0d16a45ab..33c1c862a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index 0059eac65..9cee9aacd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4a8cdd678..d5382352d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs index c2f1316df..2b756fd41 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c184bcbe5..31efb2b9c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index 5932cee1d..3fc7681c0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ce12962f..c0fe9bc08 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs index 3ab005967..9850c1e55 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4e1919c85..d0d33bed1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs index 66b9c688c..6f01e16a8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8c11aee07..f2c5d63ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -72,7 +73,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0003_TempProject_MyHubClient.g.cs index 5ea532de4..7424c518d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4bac6483d..a50da026a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0003_TempProject_MyHubClient.g.cs index 87b41323e..b6c5b7774 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 29106145e..49fb95d42 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -66,7 +67,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs index 253098b9c..56fb522f9 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0004_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 563c6e0d8..364edd7ea 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0003_TempProject_MyHubClient.g.cs index 5ce667fff..5905d3b5b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 0d16a45ab..33c1c862a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index c5a8ded3e..2fc73bd19 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4a8cdd678..d5382352d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs index c797e7b5b..69e6665be 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 55eaace57..6c7b8ec6c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0004_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0004_TempProject_MyHubClient.g.cs index 498c33530..a4209d08b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0004_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0004_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c184bcbe5..31efb2b9c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs index 3c64184f3..9c00150ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ce12962f..c0fe9bc08 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs index e697a37f0..393da72e3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4e1919c85..d0d33bed1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs index ffd1d70d1..2bc4dbf71 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8c11aee07..f2c5d63ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -72,7 +73,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0003_TempProject_MyHubClient.g.cs index e02826683..b471f2099 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4bac6483d..a50da026a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0003_TempProject_MyHubClient.g.cs index 4cc480bd6..59bb050a8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 29106145e..49fb95d42 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -66,7 +67,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs index 8bb049ceb..db9d23ca4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0004_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 31c8bbf32..cad15a649 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -84,7 +85,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 7795c640b..926c25af7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -68,7 +69,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 0d16a45ab..33c1c862a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4a8cdd678..d5382352d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c184bcbe5..31efb2b9c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ce12962f..c0fe9bc08 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8c11aee07..f2c5d63ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -72,7 +73,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4bac6483d..a50da026a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 29106145e..49fb95d42 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -66,7 +67,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 563c6e0d8..364edd7ea 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 0d16a45ab..33c1c862a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4a8cdd678..d5382352d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 55eaace57..6c7b8ec6c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c184bcbe5..31efb2b9c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ce12962f..c0fe9bc08 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4e1919c85..d0d33bed1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 8c11aee07..f2c5d63ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -72,7 +73,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4bac6483d..a50da026a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 29106145e..49fb95d42 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -66,7 +67,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 58cded831..0c7cd04fd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d1f1df5f6..5ee7015b3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d1f1df5f6..5ee7015b3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d1f1df5f6..5ee7015b3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d1f1df5f6..5ee7015b3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 58cded831..0c7cd04fd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5120f1251..a1d1dce87 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 58cded831..0c7cd04fd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 7479234db..1411ccbd2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 026347273..191cdef8d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index a7393bfc7..926f5afdb 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -64,7 +65,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0003_TempProject_MyHubClient.g.cs index 06b773a9d..860b05106 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 4afdfc23d..6c5837478 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0003_TempProject_MyHubClient.g.cs index c7e9d1f76..3cb488f50 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 89f7d8aaf..f4cf2d86f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0003_TempProject_MyHubClient.g.cs index 3a271afd1..2e7843a75 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 89f7d8aaf..f4cf2d86f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0003_TempProject_MyHubClient.g.cs index 3b828a34a..e9515c3f8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d1f1df5f6..5ee7015b3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d1f1df5f6..5ee7015b3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 2f84d83f5..87e974005 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0003_TempProject_MyHubClient.g.cs index 746553f75..75e1e1a7a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 58cded831..0c7cd04fd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0003_TempProject_MyHubClient.g.cs index 8fa1ecc22..92194d146 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5120f1251..a1d1dce87 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0003_TempProject_MyHubClient.g.cs index f2b3eea9d..a24c220b3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 89f7d8aaf..f4cf2d86f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0003_TempProject_MyHubClient.g.cs index 52281c601..372da05b3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 6cb3caa6c..10afef018 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0003_TempProject_MyHubClient.g.cs index c747de18f..1ead2b751 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 89f7d8aaf..f4cf2d86f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0003_TempProject_MyHubClient.g.cs index 10b78dec5..91a501dad 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 6cb3caa6c..10afef018 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs index a50cde281..159025216 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index aa72737d8..fd32b89ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace MyApplication1 { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs index ef51a1d9e..c644059c3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace MyApplication1.Net.Remoting { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs index 43dd2e11a..4ecea31cf 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace MyNamespace { @@ -74,7 +75,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index aa72737d8..fd32b89ba 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace MyApplication1 { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 7479234db..1411ccbd2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 7479234db..1411ccbd2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { @@ -60,7 +61,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0003_TempProject_MyHubClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0003_TempProject_MyHubClient.g.cs index 152763a69..8f54cfe63 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0003_TempProject_MyHubClient.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0003_TempProject_MyHubClient.g.cs @@ -3,6 +3,7 @@ #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS0414 // The private field 'field' is assigned but its value is never used #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace TempProject { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index 02c7b0550..95b1e658d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace MyApplication1 { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index 02c7b0550..95b1e658d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace MyApplication1 { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs index a0ec17832..8fee89505 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block using global::System; using global::MessagePack; @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index 02c7b0550..95b1e658d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete #pragma warning disable CS8019 // Unnecessary using directive. +#pragma warning disable CS1522 // Empty switch block namespace MyApplication1 { @@ -62,7 +63,7 @@ internal static object GetFormatter(global::System.Type t) } /// Type hints for Ahead-of-Time compilation. [Preserve] - internal static class TypeHints + static class TypeHints { [Preserve] internal static void Register() diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs index dd9f04664..cfeffdb66 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs @@ -79,6 +79,7 @@ public void RunAndGenerate_Service() { var (compilation, semanticModel) = CompilationHelper.Create( """ + #nullable enable using System; using MagicOnion; using MagicOnion.Client; @@ -113,6 +114,7 @@ public void RunAndGenerate_StreamingHub() { var (compilation, semanticModel) = CompilationHelper.Create( """ + #nullable enable using System; using System.Threading.Tasks; using MagicOnion; @@ -130,7 +132,7 @@ public interface IMyStreamingHubReceiver { } - [MagicOnionClientGeneration(typeof(IMyService))] + [MagicOnionClientGeneration(typeof(IMyStreamingHub))] partial class MagicOnionInitializer {} """); var sourceGenerator = new MagicOnionClientSourceGenerator(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index 6702b3f10..dda347ee2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -4,14 +4,11 @@ // https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#unit-testing-of-generators using System.Collections.Immutable; -using System.ComponentModel.DataAnnotations; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Testing; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Rename; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; using Microsoft.CodeAnalysis.Text; From ded830fe58c8fc5f8afcd0c30fb28f845bf3ccaa Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 17:54:30 +0900 Subject: [PATCH 40/66] More diagnostics --- .../MagicOnionDiagnosticDescriptors.cs | 10 +++ .../MagicOnionClientSourceGenerator.cs | 15 +++- .../GenerateTest.cs | 41 ++++++++- ...1_MyApplication1_GreeterServiceClient.g.cs | 58 ------------- ...ation1_MagicOnionInitializer_Resolver.g.cs | 79 ----------------- ..._MyApplication1_MagicOnionInitializer.g.cs | 85 ------------------- 6 files changed, 63 insertions(+), 225 deletions(-) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs index 87866f9d4..7dfccb5bb 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionDiagnosticDescriptors.cs @@ -65,4 +65,14 @@ public static class MagicOnionDiagnosticDescriptors description: "An array of rank must be less than 5.", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true); + + public static readonly DiagnosticDescriptor TypeSpecifyingClientGenerationAttributedMustBePartial = + new DiagnosticDescriptor( + id: "MOC1007", + title: "Must be partial class", + messageFormat: "The type specifying MagicOnionClientGeneration attribute must be partial class", + category: "Usage", + description: "The type specifying MagicOnionClientGeneration attribute must be partial class.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true); } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index d0a357f1a..9a40fb768 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -1,7 +1,9 @@ using System.Collections.Immutable; using MagicOnion.Client.SourceGenerator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.Utils; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.VisualBasic; namespace MagicOnion.Client.SourceGenerator; @@ -15,7 +17,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) .WithTrackingName("mo_ReferenceSymbols"); var generationAttr = context.SyntaxProvider.ForAttributeWithMetadataName( MagicOnionClientGenerationAttributeFullName, - predicate: static (node, cancellationToken) => true, + predicate: static (node, cancellationToken) => node is ClassDeclarationSyntax, transform: static (ctx, cancellationToken) => ((ClassDeclarationSyntax)ctx.TargetNode, ctx.Attributes, ctx.SemanticModel)); context.RegisterPostInitializationOutput(static context => AddAttributeSources(context.AddSource)); @@ -48,6 +50,17 @@ public void Initialize(IncrementalGeneratorInitializationContext context) // TODO: ReportDiagnostic if the class is not partial. + if (initializerClassSymbol.IsValueType) + { + sourceProductionContext.ReportDiagnostic(Diagnostic.Create(MagicOnionDiagnosticDescriptors.TypeSpecifyingClientGenerationAttributedMustBePartial, initializerClassSymbol.GetLocation())); + return; + } + if (!initializerClassDecl.Modifiers.Any(x => x.IsKind(SyntaxKind.PartialKeyword))) + { + sourceProductionContext.ReportDiagnostic(Diagnostic.Create(MagicOnionDiagnosticDescriptors.TypeSpecifyingClientGenerationAttributedMustBePartial, initializerClassSymbol.GetLocation())); + return; + } + var initializerPartialTypeNamespace = initializerClassSymbol.ContainingNamespace.IsGlobalNamespace ? null : initializerClassSymbol.ContainingNamespace.ToDisplayString(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs index d316d29ce..c08c620c3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/GenerateTest.cs @@ -1,4 +1,7 @@ +using MagicOnion.Client.SourceGenerator.CodeAnalysis; using MagicOnion.Client.SourceGenerator.Tests.Verifiers; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Testing; namespace MagicOnion.Client.SourceGenerator.Tests; @@ -43,12 +46,46 @@ public interface IGreeterService : IService } [MagicOnionClientGeneration(typeof(IGreeterService))] - class MagicOnionInitializer {} + class {|#0:MagicOnionInitializer|} {} """; - await MagicOnionSourceGeneratorVerifier.RunAsync(source); + var verifierOptions = VerifierOptions.Default with + { + TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, + ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.TypeSpecifyingClientGenerationAttributedMustBePartial.Id, DiagnosticSeverity.Error).WithLocation(0)} + }; + await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions); } + // NOTE: MagicOnionClientGeneration has `AttributeUsage(AttributeTarget.Class)` + //[Fact] + //public async Task NotClass() + //{ + // var source = """ + // using MagicOnion; + // using MagicOnion.Client; + // + // namespace MyApplication1; + // + // public interface IGreeterService : IService + // { + // UnaryResult HelloAsync(string name, int age); + // UnaryResult PingAsync(); + // UnaryResult CanGreetAsync(); + // } + // + // [MagicOnionClientGeneration(typeof(IGreeterService))] + // struct {|#0:MagicOnionInitializer|} {} + // """; + // + // var verifierOptions = VerifierOptions.Default with + // { + // TestBehaviorsOverride = TestBehaviors.SkipGeneratedSourcesCheck, + // ExpectedDiagnostics = new[] {new DiagnosticResult(MagicOnionDiagnosticDescriptors.TypeSpecifyingClientGenerationAttributedMustBePartial.Id, DiagnosticSeverity.Error).WithLocation(0)} + // }; + // await MagicOnionSourceGeneratorVerifier.RunAsync(source, verifierOptions); + //} + [Fact] public async Task Generate() { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs deleted file mode 100644 index 5fba9d3a1..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0001_MyApplication1_GreeterServiceClient.g.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MyApplication1 -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - partial class MagicOnionInitializer - { - static partial class MagicOnionGeneratedClient - { - [global::MagicOnion.Ignore] - public class MyApplication1_GreeterServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::MyApplication1.IGreeterService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker, global::System.String> HelloAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker PingAsync; - public global::MagicOnion.Client.Internal.RawMethodInvoker CanGreetAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.HelloAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_RefType, global::System.String>(global::Grpc.Core.MethodType.Unary, "IGreeterService", "HelloAsync", serializerProvider); - this.PingAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "PingAsync", serializerProvider); - this.CanGreetAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_ValueType_ValueType(global::Grpc.Core.MethodType.Unary, "IGreeterService", "CanGreetAsync", serializerProvider); - } - } - - readonly ClientCore core; - - public MyApplication1_GreeterServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private MyApplication1_GreeterServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new MyApplication1_GreeterServiceClient(options, core); - - public global::MagicOnion.UnaryResult HelloAsync(global::System.String name, global::System.Int32 age) - => this.core.HelloAsync.InvokeUnary(this, "IGreeterService/HelloAsync", new global::MagicOnion.DynamicArgumentTuple(name, age)); - public global::MagicOnion.UnaryResult PingAsync() - => this.core.PingAsync.InvokeUnaryNonGeneric(this, "IGreeterService/PingAsync", global::MessagePack.Nil.Default); - public global::MagicOnion.UnaryResult CanGreetAsync() - => this.core.CanGreetAsync.InvokeUnary(this, "IGreeterService/CanGreetAsync", global::MessagePack.Nil.Default); - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs deleted file mode 100644 index fd32b89ba..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ /dev/null @@ -1,79 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -#pragma warning disable CS1522 // Empty switch block - -namespace MyApplication1 -{ - using global::System; - using global::MessagePack; - - partial class MagicOnionInitializer - { - public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; - class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); - - MessagePackGeneratedResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MessagePackGeneratedGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - static class MessagePackGeneratedGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MessagePackGeneratedGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(1) - { - {typeof(global::MagicOnion.DynamicArgumentTuple), 0}, - }; - } - internal static object GetFormatter(global::System.Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter(default(global::System.String), default(global::System.Int32)); - default: return null; - } - } - } - /// Type hints for Ahead-of-Time compilation. - [Preserve] - static class TypeHints - { - [Preserve] - internal static void Register() - { - _ = MessagePackGeneratedResolver.Instance.GetFormatter>(); - _ = MessagePackGeneratedResolver.Instance.GetFormatter(); - _ = MessagePackGeneratedResolver.Instance.GetFormatter(); - _ = MessagePackGeneratedResolver.Instance.GetFormatter(); - _ = MessagePackGeneratedResolver.Instance.GetFormatter(); - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs deleted file mode 100644 index dbde9de8e..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0003_MyApplication1_MagicOnionInitializer.g.cs +++ /dev/null @@ -1,85 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. -namespace MyApplication1 -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - partial class PreserveAttribute : global::System.Attribute {} - - partial class MagicOnionInitializer - { - static bool isRegistered = false; - readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); - - public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; - public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; -#if UNITY_2019_4_OR_NEWER - [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [global::System.Runtime.CompilerServices.ModuleInitializer] -#endif - internal static void Register() => TryRegisterProviderFactory(); - - public static bool TryRegisterProviderFactory() - { - if (isRegistered) return false; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(provider); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(provider) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(provider); - - return true; - } - - class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::MyApplication1.IGreeterService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new MagicOnionGeneratedClient.MyApplication1_GreeterServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - } -} From 8985148869ea9fe2ca3eecc586a64b3c9256fbdc Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 18:01:53 +0900 Subject: [PATCH 41/66] Fix EnumFormatter --- .../CodeGen/MessagePackEnumFormatterGenerator.cs | 2 +- .../MagicOnionClientSourceGenerator.cs | 6 ++---- ...OnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...ct_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs | 2 +- ...OnionInitializer_Formatters_ApartmentStateFormatter.g.cs | 2 +- ...ializer_Formatters_ClientCertificateOptionFormatter.g.cs | 2 +- ..._MagicOnionInitializer_Formatters_FileModeFormatter.g.cs | 2 +- ...Initializer_Formatters_TaskCreationOptionsFormatter.g.cs | 2 +- 19 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs index cc8ef0ba9..baf9cbe0b 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs @@ -29,7 +29,7 @@ namespace {{context.Namespace}} partial class {{context.InitializerPartialTypeName}} { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { """); diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 9a40fb768..40db8dd80 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -3,7 +3,7 @@ using MagicOnion.Client.SourceGenerator.Utils; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.VisualBasic; +using Microsoft.CodeAnalysis.CSharp; namespace MagicOnion.Client.SourceGenerator; @@ -46,9 +46,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) } var initializerClassSymbol = semanticModel.GetDeclaredSymbol(initializerClassDecl) as INamedTypeSymbol; - if (initializerClassSymbol is null) return; // TODO: ReportDiagnostic - - // TODO: ReportDiagnostic if the class is not partial. + if (initializerClassSymbol is null) return; if (initializerClassSymbol.IsValueType) { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs index e77b2d472..4ccaad5c7 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyClass_MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs index 0106a7ff3..a5668cf6f 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs @@ -10,7 +10,7 @@ namespace TempProject partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs index c50a99a1e..6838f16bb 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs @@ -10,7 +10,7 @@ namespace MyNamespace partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class ApartmentStateFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs index 9f1fb8edf..61df15e16 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs @@ -10,7 +10,7 @@ namespace MyNamespace partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class ClientCertificateOptionFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs index 7f206d20a..6b51ab1a0 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs @@ -10,7 +10,7 @@ namespace MyNamespace partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class FileModeFormatter : global::MessagePack.Formatters.IMessagePackFormatter { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs index 95853d73b..195614671 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs @@ -10,7 +10,7 @@ namespace MyNamespace partial class MagicOnionInitializer { - static class MessagePackEnumFormatters + static partial class MessagePackEnumFormatters { public sealed class TaskCreationOptionsFormatter : global::MessagePack.Formatters.IMessagePackFormatter { From daeeb3c8d52f1a8fdaf524eaa545e01214a6ce0b Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 18:08:14 +0900 Subject: [PATCH 42/66] Fix EnumFormatter generation --- .../MagicOnionClientGenerator.cs | 4 +- ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ...MagicOnionInitializer_EnumFormatters.g.cs} | 0 ..._MagicOnionInitializer_EnumFormatters.g.cs | 65 +++++++++++++++++++ ...er_Formatters_ApartmentStateFormatter.g.cs | 29 --------- ...ters_ClientCertificateOptionFormatter.g.cs | 29 --------- ...space_MagicOnionInitializer_Resolver.g.cs} | 0 ...03_MyNamespace_MagicOnionInitializer.g.cs} | 0 ...tializer_Formatters_FileModeFormatter.g.cs | 29 --------- ...rmatters_TaskCreationOptionsFormatter.g.cs | 29 --------- ... => 0004_MyNamespace_MyServiceClient.g.cs} | 0 22 files changed, 67 insertions(+), 118 deletions(-) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/{0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/{0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs => 0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs} (100%) create mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_EnumFormatters.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs => 0002_MyNamespace_MagicOnionInitializer_Resolver.g.cs} (100%) rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{0006_MyNamespace_MagicOnionInitializer.g.cs => 0003_MyNamespace_MagicOnionInitializer.g.cs} (100%) delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs delete mode 100644 tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs rename tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/{0007_MyNamespace_MyServiceClient.g.cs => 0004_MyNamespace_MyServiceClient.g.cs} (100%) diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs index 49c661a32..f8683f14f 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs @@ -42,9 +42,9 @@ public static class MagicOnionClientGenerator outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName), MagicOnionInitializerGenerator.Build(context, serviceCollection))); outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".Resolver"), resolverTexts)); - foreach (var enumSerializationInfo in serializationInfoCollection.Enums) + if (serializationInfoCollection.Enums.Any()) { - outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".Formatters." + enumSerializationInfo.FormatterName), serialization.EnumFormatterGenerator(new []{ enumSerializationInfo }))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".EnumFormatters"), serialization.EnumFormatterGenerator(serializationInfoCollection.Enums))); } foreach (var service in serviceCollection.Services) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_Formatters_MyClass_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_Formatters_MyEnumFormatter.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0001_TempProject_MagicOnionInitializer_EnumFormatters.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_EnumFormatters.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_EnumFormatters.g.cs new file mode 100644 index 000000000..351f188b9 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_EnumFormatters.g.cs @@ -0,0 +1,65 @@ +// +#pragma warning disable CS0618 // 'member' is obsolete: 'text' +#pragma warning disable CS0612 // 'member' is obsolete +#pragma warning disable CS8019 // Unnecessary using directive. + +namespace MyNamespace +{ + using global::System; + using global::MessagePack; + + partial class MagicOnionInitializer + { + static partial class MessagePackEnumFormatters + { + public sealed class FileModeFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.IO.FileMode value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.IO.FileMode Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::System.IO.FileMode)reader.ReadInt32(); + } + } + public sealed class ClientCertificateOptionFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Net.Http.ClientCertificateOption value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.Net.Http.ClientCertificateOption Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::System.Net.Http.ClientCertificateOption)reader.ReadInt32(); + } + } + public sealed class ApartmentStateFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Threading.ApartmentState value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.Threading.ApartmentState Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::System.Threading.ApartmentState)reader.ReadInt32(); + } + } + public sealed class TaskCreationOptionsFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Threading.Tasks.TaskCreationOptions value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((Int32)value); + } + + public global::System.Threading.Tasks.TaskCreationOptions Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::System.Threading.Tasks.TaskCreationOptions)reader.ReadInt32(); + } + } + } + } +} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs deleted file mode 100644 index 6838f16bb..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0001_MyNamespace_MagicOnionInitializer_Formatters_ApartmentStateFormatter.g.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MyNamespace -{ - using global::System; - using global::MessagePack; - - partial class MagicOnionInitializer - { - static partial class MessagePackEnumFormatters - { - public sealed class ApartmentStateFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Threading.ApartmentState value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::System.Threading.ApartmentState Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::System.Threading.ApartmentState)reader.ReadInt32(); - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs deleted file mode 100644 index 61df15e16..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Formatters_ClientCertificateOptionFormatter.g.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MyNamespace -{ - using global::System; - using global::MessagePack; - - partial class MagicOnionInitializer - { - static partial class MessagePackEnumFormatters - { - public sealed class ClientCertificateOptionFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Net.Http.ClientCertificateOption value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::System.Net.Http.ClientCertificateOption Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::System.Net.Http.ClientCertificateOption)reader.ReadInt32(); - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Resolver.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0005_MyNamespace_MagicOnionInitializer_Resolver.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Resolver.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0006_MyNamespace_MagicOnionInitializer.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer.g.cs diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs deleted file mode 100644 index 6b51ab1a0..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer_Formatters_FileModeFormatter.g.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MyNamespace -{ - using global::System; - using global::MessagePack; - - partial class MagicOnionInitializer - { - static partial class MessagePackEnumFormatters - { - public sealed class FileModeFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.IO.FileMode value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::System.IO.FileMode Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::System.IO.FileMode)reader.ReadInt32(); - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs deleted file mode 100644 index 195614671..000000000 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MagicOnionInitializer_Formatters_TaskCreationOptionsFormatter.g.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -#pragma warning disable CS0618 // 'member' is obsolete: 'text' -#pragma warning disable CS0612 // 'member' is obsolete -#pragma warning disable CS8019 // Unnecessary using directive. - -namespace MyNamespace -{ - using global::System; - using global::MessagePack; - - partial class MagicOnionInitializer - { - static partial class MessagePackEnumFormatters - { - public sealed class TaskCreationOptionsFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::System.Threading.Tasks.TaskCreationOptions value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::System.Threading.Tasks.TaskCreationOptions Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::System.Threading.Tasks.TaskCreationOptions)reader.ReadInt32(); - } - } - } - } -} diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MyServiceClient.g.cs similarity index 100% rename from tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0007_MyNamespace_MyServiceClient.g.cs rename to tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0004_MyNamespace_MyServiceClient.g.cs From 7a7710fa7978259d0502196e53268d774c726bea Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 18:10:40 +0900 Subject: [PATCH 43/66] Fix comment --- .../MagicOnionClientSourceGenerator.Emit.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs index 431b5605c..f22340f8a 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs @@ -30,7 +30,7 @@ internal class {{MagicOnionClientGenerationAttributeName}} : global::System.Attr public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; From a7a4833b09283eaa221a6628b57fb4cf5e64ea4f Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 19:28:58 +0900 Subject: [PATCH 44/66] Fix generator for Unity --- MagicOnion.sln | 7 ++ ...cOnion.Client.SourceGenerator.Unity.csproj | 1 + ...MagicOnionClientSourceGenerator.Roslyn3.cs | 52 +++++++-- .../GenerationContext.cs | 27 +---- .../MagicOnionClientSourceGenerator.Parse.cs | 104 ++++++++++++++++++ .../MagicOnionClientSourceGenerator.cs | 56 +--------- ...cOnion.Client.SourceGenerator.Tests.csproj | 6 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- ...cOnionClientSourceGeneratorAttributes.g.cs | 2 +- .../RunTest.cs | 2 +- .../GlobalUsings.cs | 1 + ....Client.SourceGenerator.Unity.Tests.csproj | 55 +++++++++ .../MicrosoftCodeAnalysisExtensions.cs | 9 ++ 98 files changed, 313 insertions(+), 181 deletions(-) create mode 100644 src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Parse.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Unity.Tests/GlobalUsings.cs create mode 100644 tests/MagicOnion.Client.SourceGenerator.Unity.Tests/MagicOnion.Client.SourceGenerator.Unity.Tests.csproj create mode 100644 tests/MagicOnion.Client.SourceGenerator.Unity.Tests/MicrosoftCodeAnalysisExtensions.cs diff --git a/MagicOnion.sln b/MagicOnion.sln index cf57a0cd7..3032896d8 100644 --- a/MagicOnion.sln +++ b/MagicOnion.sln @@ -106,6 +106,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGen EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleServiceDefinitions", "tests\samples\SampleServiceDefinitions\SampleServiceDefinitions.csproj", "{45EA8028-41C1-4DF6-9E0F-EEE8967799DA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicOnion.Client.SourceGenerator.Unity.Tests", "tests\MagicOnion.Client.SourceGenerator.Unity.Tests\MagicOnion.Client.SourceGenerator.Unity.Tests.csproj", "{AFB26C11-0833-459D-B071-7CA001BD7F01}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -236,6 +238,10 @@ Global {45EA8028-41C1-4DF6-9E0F-EEE8967799DA}.Debug|Any CPU.Build.0 = Debug|Any CPU {45EA8028-41C1-4DF6-9E0F-EEE8967799DA}.Release|Any CPU.ActiveCfg = Release|Any CPU {45EA8028-41C1-4DF6-9E0F-EEE8967799DA}.Release|Any CPU.Build.0 = Release|Any CPU + {AFB26C11-0833-459D-B071-7CA001BD7F01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AFB26C11-0833-459D-B071-7CA001BD7F01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AFB26C11-0833-459D-B071-7CA001BD7F01}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AFB26C11-0833-459D-B071-7CA001BD7F01}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -277,6 +283,7 @@ Global {632C8D1B-3293-4D02-9ED1-0CB191619334} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD} = {1987061F-8970-4018-8D58-6932961C9EB4} {45EA8028-41C1-4DF6-9E0F-EEE8967799DA} = {B5617CC1-55FD-4F77-BA75-9450474C6527} + {AFB26C11-0833-459D-B071-7CA001BD7F01} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D5B2E7E3-B727-40A1-BE68-7BAC9B9DE2FE} diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj index c16514c78..6e3168277 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -23,6 +23,7 @@ + diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs index ef38fb7ab..e30718f4e 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs @@ -1,7 +1,6 @@ -using System.Collections.Immutable; using MagicOnion.Client.SourceGenerator.CodeAnalysis; -using MagicOnion.Client.SourceGenerator.Internal; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; namespace MagicOnion.Client.SourceGenerator; @@ -16,24 +15,55 @@ public void Initialize(GeneratorInitializationContext context) public void Execute(GeneratorExecutionContext context) { - var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxReceiver!; - if (ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) + var syntaxReceiver = (SyntaxContextReceiver)context.SyntaxContextReceiver!; + if (syntaxReceiver.Candidates.Any() && ReferenceSymbols.TryCreate(context.Compilation, out var referenceSymbols)) { - var generationContext = new GenerationContext(null, "MagicOnionInitializer", new SourceProductionContext(context)); - Generate(generationContext, syntaxReceiver.Candidates.ToImmutableArray(), context.Compilation, referenceSymbols); + var sourceProductionContext = new SourceProductionContext(context); + + foreach (var (initializerClassDecl, semanticModel) in syntaxReceiver.Candidates) + { + var classSymbol = semanticModel.GetDeclaredSymbol(initializerClassDecl) as INamedTypeSymbol; + if (classSymbol is null) continue; + + var attrs = classSymbol.GetAttributes(); + var attr = attrs.FirstOrDefault(x => x.AttributeClass?.Name == MagicOnionClientGenerationAttributeName); + if (attr is null) return; // TODO: ReportDiagnostic + + var options = ParseClientGenerationOptions(attr); + if (!TryParseClientGenerationSpec(sourceProductionContext, semanticModel, initializerClassDecl, attr, out var spec)) + { + return; + } + + var generationContext = new GenerationContext(spec.InitializerPartialTypeNamespace, spec.InitializerPartialTypeName, sourceProductionContext, options); + Generate(generationContext, spec.InterfaceSymbols, referenceSymbols); + } } } } -class SyntaxContextReceiver : ISyntaxReceiver +class SyntaxContextReceiver : ISyntaxContextReceiver { - public List Candidates { get; } = new(); + public List<(ClassDeclarationSyntax Node, SemanticModel SemanticModel)> Candidates { get; } = new(); - public void OnVisitSyntaxNode(SyntaxNode syntaxNode) + public void OnVisitSyntaxNode(GeneratorSyntaxContext context) { - if (SyntaxHelper.IsCandidateInterface(syntaxNode)) + if (context.Node is ClassDeclarationSyntax classDeclSyntax) { - Candidates.Add(syntaxNode); + foreach (var attrList in classDeclSyntax.AttributeLists) + { + foreach (var attr in attrList.Attributes) + { + var attrSymbol = context.SemanticModel.GetSymbolInfo(attr).Symbol as IMethodSymbol; + if (attrSymbol is null) continue; + + var attrContainingType = attrSymbol.ContainingType; + if (attrContainingType.ToDisplayString() == MagicOnionClientSourceGenerator.MagicOnionClientGenerationAttributeFullName) + { + Candidates.Add((classDeclSyntax,context.SemanticModel)); + } + } + } } } } diff --git a/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs b/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs index a55f97a4a..5f9e2f216 100644 --- a/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs +++ b/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs @@ -19,30 +19,5 @@ public enum SerializerType public record GenerationOptions(SerializerType Serializer, bool DisableAutoRegistration, string MessagePackFormatterNamespace) { - public static GenerationOptions Default { get; } = new GenerationOptions(SerializerType.MessagePack, false, "MessagePack.Formatters"); - - public static GenerationOptions Parse(AttributeData attr) - { - var options = GenerationOptions.Default; - - foreach (var namedArg in attr.NamedArguments) - { - if (namedArg.Value.Kind is TypedConstantKind.Error or not TypedConstantKind.Primitive) continue; - - switch (namedArg.Key) - { - case nameof(GenerationOptions.DisableAutoRegistration): - options = options with { DisableAutoRegistration = (bool)namedArg.Value.Value! }; - break; - case nameof(GenerationOptions.Serializer): - options = options with { Serializer = (SerializerType)(int)namedArg.Value.Value! }; - break; - case nameof(GenerationOptions.MessagePackFormatterNamespace): - options = options with { MessagePackFormatterNamespace = (string)namedArg.Value.Value! }; - break; - } - } - - return options; - } + public static GenerationOptions Default { get; } = new (SerializerType.MessagePack, false, "MessagePack.Formatters"); } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Parse.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Parse.cs new file mode 100644 index 000000000..61bafab74 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Parse.cs @@ -0,0 +1,104 @@ +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.Utils; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace MagicOnion.Client.SourceGenerator; + +public partial class MagicOnionClientSourceGenerator +{ + static bool TryParseClientGenerationSpec(SourceProductionContext sourceProductionContext, SemanticModel semanticModel, ClassDeclarationSyntax initializerDeclarationSyntax, AttributeData attr, [NotNullWhen(true)] out ClientGenerationSpec? spec) + { + // If the constructor has errors in the arguments, the first argument may be `Type` instead of `Array`. We need `Array` to proceed. + if (attr.ConstructorArguments[0].Kind != TypedConstantKind.Array) + { + spec = null; + return false; // TODO: ReportDiagnostic + } + + var interfaceSymbols = new List(); + foreach (var typeContainedInTargetAssembly in attr.ConstructorArguments[0].Values) // Type[] typesContainedInTargetAssembly + { + if (typeContainedInTargetAssembly.Value is INamedTypeSymbol typeSymbolContainedInTargetAssembly) + { + var scanTargetAssembly = typeSymbolContainedInTargetAssembly.ContainingAssembly; + if (scanTargetAssembly is null) continue; + + Traverse(scanTargetAssembly.GlobalNamespace, interfaceSymbols); + } + } + + var initializerClassSymbol = semanticModel.GetDeclaredSymbol(initializerDeclarationSyntax) as INamedTypeSymbol; + if (initializerClassSymbol is null) + { + spec = null; + return false; + } + + if (initializerClassSymbol.IsValueType) + { + sourceProductionContext.ReportDiagnostic(Diagnostic.Create(MagicOnionDiagnosticDescriptors.TypeSpecifyingClientGenerationAttributedMustBePartial, initializerClassSymbol.GetLocation())); + spec = null; + return false; + } + if (!initializerDeclarationSyntax.Modifiers.Any(x => x.IsKind(SyntaxKind.PartialKeyword))) + { + sourceProductionContext.ReportDiagnostic(Diagnostic.Create(MagicOnionDiagnosticDescriptors.TypeSpecifyingClientGenerationAttributedMustBePartial, initializerClassSymbol.GetLocation())); + spec = null; + return false; + } + + var initializerPartialTypeNamespace = initializerClassSymbol.ContainingNamespace.IsGlobalNamespace + ? null + : initializerClassSymbol.ContainingNamespace.ToDisplayString(); + var initializerPartialTypeName = initializerClassSymbol.Name; + + spec = new ClientGenerationSpec(initializerPartialTypeNamespace, initializerPartialTypeName, interfaceSymbols.ToImmutableArray()); + return true; + + static void Traverse(INamespaceOrTypeSymbol rootNamespaceOrTypeSymbol, List interfaceSymbols) + { + foreach (var namespaceOrTypeSymbol in rootNamespaceOrTypeSymbol.GetMembers()) + { + if (namespaceOrTypeSymbol is INamedTypeSymbol { TypeKind: TypeKind.Interface } typeSymbol) + { + interfaceSymbols.Add(typeSymbol); + } + else if (namespaceOrTypeSymbol is INamespaceSymbol namespaceSymbol) + { + Traverse(namespaceSymbol, interfaceSymbols); + } + } + } + } + + static GenerationOptions ParseClientGenerationOptions(AttributeData attr) + { + var options = GenerationOptions.Default; + + foreach (var namedArg in attr.NamedArguments) + { + if (namedArg.Value.Kind is TypedConstantKind.Error or not TypedConstantKind.Primitive) continue; + + switch (namedArg.Key) + { + case nameof(GenerationOptions.DisableAutoRegistration): + options = options with { DisableAutoRegistration = (bool)namedArg.Value.Value! }; + break; + case nameof(GenerationOptions.Serializer): + options = options with { Serializer = (SerializerType)(int)namedArg.Value.Value! }; + break; + case nameof(GenerationOptions.MessagePackFormatterNamespace): + options = options with { MessagePackFormatterNamespace = (string)namedArg.Value.Value! }; + break; + } + } + + return options; + } + + record ClientGenerationSpec(string? InitializerPartialTypeNamespace, string InitializerPartialTypeName, ImmutableArray InterfaceSymbols); +} diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 40db8dd80..83d43a4e8 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -1,9 +1,6 @@ -using System.Collections.Immutable; using MagicOnion.Client.SourceGenerator.CodeAnalysis; -using MagicOnion.Client.SourceGenerator.Utils; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.CSharp; namespace MagicOnion.Client.SourceGenerator; @@ -27,62 +24,17 @@ public void Initialize(IncrementalGeneratorInitializationContext context) var ((initializerClassDecl, attrs, semanticModel), referenceSymbols) = value; if (referenceSymbols is null) return; // TODO: ReportDiagnostic - var interfaceSymbols = new List(); var attr = attrs.FirstOrDefault(x => x.AttributeClass?.Name == MagicOnionClientGenerationAttributeName); if (attr is null) return; // TODO: ReportDiagnostic - // If the constructor has errors in the arguments, the first argument may be `Type` instead of `Array`. We need `Array` to proceed. - if (attr.ConstructorArguments[0].Kind != TypedConstantKind.Array) return; // TODO: ReportDiagnostic - - foreach (var typeContainedInTargetAssembly in attr.ConstructorArguments[0].Values) // Type[] typesContainedInTargetAssembly - { - if (typeContainedInTargetAssembly.Value is INamedTypeSymbol typeSymbolContainedInTargetAssembly) - { - var scanTargetAssembly = typeSymbolContainedInTargetAssembly.ContainingAssembly; - if (scanTargetAssembly is null) continue; - - Traverse(scanTargetAssembly.GlobalNamespace, interfaceSymbols); - } - } - - var initializerClassSymbol = semanticModel.GetDeclaredSymbol(initializerClassDecl) as INamedTypeSymbol; - if (initializerClassSymbol is null) return; - - if (initializerClassSymbol.IsValueType) - { - sourceProductionContext.ReportDiagnostic(Diagnostic.Create(MagicOnionDiagnosticDescriptors.TypeSpecifyingClientGenerationAttributedMustBePartial, initializerClassSymbol.GetLocation())); - return; - } - if (!initializerClassDecl.Modifiers.Any(x => x.IsKind(SyntaxKind.PartialKeyword))) + var options = ParseClientGenerationOptions(attr); + if (!TryParseClientGenerationSpec(sourceProductionContext, semanticModel, initializerClassDecl, attr, out var spec)) { - sourceProductionContext.ReportDiagnostic(Diagnostic.Create(MagicOnionDiagnosticDescriptors.TypeSpecifyingClientGenerationAttributedMustBePartial, initializerClassSymbol.GetLocation())); return; } - var initializerPartialTypeNamespace = initializerClassSymbol.ContainingNamespace.IsGlobalNamespace - ? null - : initializerClassSymbol.ContainingNamespace.ToDisplayString(); - var initializerPartialTypeName = initializerClassSymbol.Name; - - var option = GenerationOptions.Parse(attr); - var generationContext = new GenerationContext(initializerPartialTypeNamespace, initializerPartialTypeName, sourceProductionContext, option); - Generate(generationContext, interfaceSymbols.ToImmutableArray(), referenceSymbols); - - static void Traverse(INamespaceOrTypeSymbol rootNamespaceOrTypeSymbol, List interfaceSymbols) - { - foreach (var namespaceOrTypeSymbol in rootNamespaceOrTypeSymbol.GetMembers()) - { - if (namespaceOrTypeSymbol is INamedTypeSymbol { TypeKind: TypeKind.Interface } typeSymbol) - { - interfaceSymbols.Add(typeSymbol); - } - else if (namespaceOrTypeSymbol is INamespaceSymbol namespaceSymbol) - { - Traverse(namespaceSymbol, interfaceSymbols); - } - } - } + var generationContext = new GenerationContext(spec.InitializerPartialTypeNamespace, spec.InitializerPartialTypeName, sourceProductionContext, options); + Generate(generationContext, spec.InterfaceSymbols, referenceSymbols); }); } - } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj index 7f275bbb2..48baa2750 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/MagicOnion.Client.SourceGenerator.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -38,12 +38,10 @@ + - - - diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 1a6ef5995..8b9c206ef 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -15,7 +15,7 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute public bool DisableAutoRegistration { get; init; } /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Gets or set the serializer used for message serialization. The default value is . /// public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs index cfeffdb66..0e457a73d 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/RunTest.cs @@ -26,7 +26,7 @@ public interface IMyService : IService UnaryResult HelloAsync(string name, int age); } - [MagicOnionClientGeneration(typeof(IMyService))] + [MagicOnion.Client.MagicOnionClientGeneration(typeof(IMyService))] partial class MagicOnionInitializer {} """); var sourceGenerator = new MagicOnionClientSourceGenerator(); diff --git a/tests/MagicOnion.Client.SourceGenerator.Unity.Tests/GlobalUsings.cs b/tests/MagicOnion.Client.SourceGenerator.Unity.Tests/GlobalUsings.cs new file mode 100644 index 000000000..8c927eb74 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Unity.Tests/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/tests/MagicOnion.Client.SourceGenerator.Unity.Tests/MagicOnion.Client.SourceGenerator.Unity.Tests.csproj b/tests/MagicOnion.Client.SourceGenerator.Unity.Tests/MagicOnion.Client.SourceGenerator.Unity.Tests.csproj new file mode 100644 index 000000000..522147107 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Unity.Tests/MagicOnion.Client.SourceGenerator.Unity.Tests.csproj @@ -0,0 +1,55 @@ + + + + + net6.0 + latest + enable + enable + + false + MagicOnion.Client.SourceGenerator.Tests + MagicOnion.Client.SourceGenerator.Tests + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/MagicOnion.Client.SourceGenerator.Unity.Tests/MicrosoftCodeAnalysisExtensions.cs b/tests/MagicOnion.Client.SourceGenerator.Unity.Tests/MicrosoftCodeAnalysisExtensions.cs new file mode 100644 index 000000000..186ff0e88 --- /dev/null +++ b/tests/MagicOnion.Client.SourceGenerator.Unity.Tests/MicrosoftCodeAnalysisExtensions.cs @@ -0,0 +1,9 @@ +using Microsoft.CodeAnalysis; + +// ReSharper disable once CheckNamespace +namespace MagicOnion.Client.SourceGenerator.Tests; + +internal static class MicrosoftCodeAnalysisExtensions +{ + public static ISourceGenerator AsSourceGenerator(this ISourceGenerator generator) => generator; // Shim +} From 9fc9380f70d7232544af9fcf2a16c3e98b374e7b Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 19:40:20 +0900 Subject: [PATCH 45/66] Use getters instead --- .../MagicOnionClientSourceGenerator.Emit.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../0000_MagicOnionClientSourceGeneratorAttributes.g.cs | 6 +++--- .../Verifiers/MagicOnionSourceGeneratorVerifier.cs | 2 +- 89 files changed, 265 insertions(+), 265 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs index f22340f8a..a14b65cde 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs @@ -27,17 +27,17 @@ internal class {{MagicOnionClientGenerationAttributeName}} : global::System.Attr /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NoGenerate/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/NotPartial/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs index 8b9c206ef..a72474002 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0000_MagicOnionClientSourceGeneratorAttributes.g.cs @@ -12,17 +12,17 @@ internal class MagicOnionClientGenerationAttribute : global::System.Attribute /// /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) /// - public bool DisableAutoRegistration { get; init; } + public bool DisableAutoRegistration { get; set; } /// /// Gets or set the serializer used for message serialization. The default value is . /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; init; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; /// /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. /// - public string MessagePackFormatterNamespace { get; init; } = "MessagePack.Formatters"; + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; public global::System.Type[] TypesContainedInTargetAssembly { get; } diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index dda347ee2..84b422278 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -1,4 +1,4 @@ -//#define WRITE_EXPECTED +#define WRITE_EXPECTED // https://github.com/MessagePack-CSharp/MessagePack-CSharp/blob/develop/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier%601%2BTest.cs // https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#unit-testing-of-generators From 93a01e261f842d010fdc8087a45a70169da492c8 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 19:40:35 +0900 Subject: [PATCH 46/66] Fix --- .../Verifiers/MagicOnionSourceGeneratorVerifier.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs index 84b422278..dda347ee2 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Verifiers/MagicOnionSourceGeneratorVerifier.cs @@ -1,4 +1,4 @@ -#define WRITE_EXPECTED +//#define WRITE_EXPECTED // https://github.com/MessagePack-CSharp/MessagePack-CSharp/blob/develop/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier%601%2BTest.cs // https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#unit-testing-of-generators From 9bfd96f78f928369556708f1a70176e25c93b0d9 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 18 Oct 2023 20:17:49 +0900 Subject: [PATCH 47/66] Remove unused file --- .../MagicOnion.Client.SourceGenerator.csproj | 9 +-------- .../build/MagicOnion.Client.SourceGenerator.target | 5 ----- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 src/MagicOnion.Client.SourceGenerator/build/MagicOnion.Client.SourceGenerator.target diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index 5aac9156f..1e60b7f71 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -26,13 +26,6 @@ - - - true - build\ - - - diff --git a/src/MagicOnion.Client.SourceGenerator/build/MagicOnion.Client.SourceGenerator.target b/src/MagicOnion.Client.SourceGenerator/build/MagicOnion.Client.SourceGenerator.target deleted file mode 100644 index 9708ab755..000000000 --- a/src/MagicOnion.Client.SourceGenerator/build/MagicOnion.Client.SourceGenerator.target +++ /dev/null @@ -1,5 +0,0 @@ - - - - - From 69c1ee6606270a39fe74874ffbce4757643aed99 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 19 Oct 2023 11:01:47 +0900 Subject: [PATCH 48/66] Upgrade to Unity 2021.3.0f1 --- .../ChatApp.Unity/Packages/manifest.json | 5 +- .../ProjectSettings/MemorySettings.asset | 35 ++++ .../ProjectSettings/ProjectSettings.asset | 108 ++++++++++- .../ProjectSettings/ProjectVersion.txt | 4 +- .../SceneTemplateSettings.json | 167 ++++++++++++++++++ .../ChatApp.Unity/ProjectSettings/boot.config | 0 6 files changed, 310 insertions(+), 9 deletions(-) create mode 100644 samples/ChatApp/ChatApp.Unity/ProjectSettings/MemorySettings.asset create mode 100644 samples/ChatApp/ChatApp.Unity/ProjectSettings/SceneTemplateSettings.json create mode 100644 samples/ChatApp/ChatApp.Unity/ProjectSettings/boot.config diff --git a/samples/ChatApp/ChatApp.Unity/Packages/manifest.json b/samples/ChatApp/ChatApp.Unity/Packages/manifest.json index 1b4439bae..39401eca4 100644 --- a/samples/ChatApp/ChatApp.Unity/Packages/manifest.json +++ b/samples/ChatApp/ChatApp.Unity/Packages/manifest.json @@ -7,14 +7,13 @@ "com.unity.ads": "3.7.5", "com.unity.analytics": "3.6.12", "com.unity.collab-proxy": "1.15.15", - "com.unity.ide.rider": "2.0.7", + "com.unity.ide.rider": "3.0.13", "com.unity.ide.visualstudio": "2.0.14", "com.unity.ide.vscode": "1.2.5", - "com.unity.multiplayer-hlapi": "1.0.8", "com.unity.purchasing": "4.1.3", "com.unity.test-framework": "1.1.31", "com.unity.textmeshpro": "3.0.6", - "com.unity.timeline": "1.4.8", + "com.unity.timeline": "1.6.4", "com.unity.ugui": "1.0.0", "com.unity.xr.legacyinputhelpers": "2.1.9", "com.unity.modules.ai": "1.0.0", diff --git a/samples/ChatApp/ChatApp.Unity/ProjectSettings/MemorySettings.asset b/samples/ChatApp/ChatApp.Unity/ProjectSettings/MemorySettings.asset new file mode 100644 index 000000000..5b5faceca --- /dev/null +++ b/samples/ChatApp/ChatApp.Unity/ProjectSettings/MemorySettings.asset @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!387306366 &1 +MemorySettings: + m_ObjectHideFlags: 0 + m_EditorMemorySettings: + m_MainAllocatorBlockSize: -1 + m_ThreadAllocatorBlockSize: -1 + m_MainGfxBlockSize: -1 + m_ThreadGfxBlockSize: -1 + m_CacheBlockSize: -1 + m_TypetreeBlockSize: -1 + m_ProfilerBlockSize: -1 + m_ProfilerEditorBlockSize: -1 + m_BucketAllocatorGranularity: -1 + m_BucketAllocatorBucketsCount: -1 + m_BucketAllocatorBlockSize: -1 + m_BucketAllocatorBlockCount: -1 + m_ProfilerBucketAllocatorGranularity: -1 + m_ProfilerBucketAllocatorBucketsCount: -1 + m_ProfilerBucketAllocatorBlockSize: -1 + m_ProfilerBucketAllocatorBlockCount: -1 + m_TempAllocatorSizeMain: -1 + m_JobTempAllocatorBlockSize: -1 + m_BackgroundJobTempAllocatorBlockSize: -1 + m_JobTempAllocatorReducedBlockSize: -1 + m_TempAllocatorSizeGIBakingWorker: -1 + m_TempAllocatorSizeNavMeshWorker: -1 + m_TempAllocatorSizeAudioWorker: -1 + m_TempAllocatorSizeCloudWorker: -1 + m_TempAllocatorSizeGfx: -1 + m_TempAllocatorSizeJobWorker: -1 + m_TempAllocatorSizeBackgroundWorker: -1 + m_TempAllocatorSizePreloadManager: -1 + m_PlatformMemorySettings: {} diff --git a/samples/ChatApp/ChatApp.Unity/ProjectSettings/ProjectSettings.asset b/samples/ChatApp/ChatApp.Unity/ProjectSettings/ProjectSettings.asset index 8764d91a0..3ac29003e 100644 --- a/samples/ChatApp/ChatApp.Unity/ProjectSettings/ProjectSettings.asset +++ b/samples/ChatApp/ChatApp.Unity/ProjectSettings/ProjectSettings.asset @@ -3,7 +3,7 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 22 + serializedVersion: 23 productGUID: 7b98bc9fa599ce549a0f73dfca1a2746 AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 @@ -218,6 +218,7 @@ PlayerSettings: iOSLaunchScreeniPadCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] + macOSURLSchemes: [] iOSBackgroundModes: 0 iOSMetalForceHardShadows: 0 metalEditorSupport: 1 @@ -362,6 +363,103 @@ PlayerSettings: m_Height: 36 m_Kind: 1 m_SubKind: + - m_BuildTarget: iPhone + m_Icons: + - m_Textures: [] + m_Width: 180 + m_Height: 180 + m_Kind: 0 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 120 + m_Height: 120 + m_Kind: 0 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 167 + m_Height: 167 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 152 + m_Height: 152 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 76 + m_Height: 76 + m_Kind: 0 + m_SubKind: iPad + - m_Textures: [] + m_Width: 120 + m_Height: 120 + m_Kind: 3 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 80 + m_Height: 80 + m_Kind: 3 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 80 + m_Height: 80 + m_Kind: 3 + m_SubKind: iPad + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 3 + m_SubKind: iPad + - m_Textures: [] + m_Width: 87 + m_Height: 87 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 58 + m_Height: 58 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 29 + m_Height: 29 + m_Kind: 1 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 58 + m_Height: 58 + m_Kind: 1 + m_SubKind: iPad + - m_Textures: [] + m_Width: 29 + m_Height: 29 + m_Kind: 1 + m_SubKind: iPad + - m_Textures: [] + m_Width: 60 + m_Height: 60 + m_Kind: 2 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 2 + m_SubKind: iPhone + - m_Textures: [] + m_Width: 40 + m_Height: 40 + m_Kind: 2 + m_SubKind: iPad + - m_Textures: [] + m_Width: 20 + m_Height: 20 + m_Kind: 2 + m_SubKind: iPad + - m_Textures: [] + m_Width: 1024 + m_Height: 1024 + m_Kind: 4 + m_SubKind: App Store m_BuildTargetBatching: - m_BuildTarget: Standalone m_StaticBatching: 1 @@ -421,7 +519,7 @@ PlayerSettings: m_BuildTargetGraphicsAPIs: - m_BuildTarget: AndroidPlayer m_APIs: 0b00000008000000 - m_Automatic: 1 + m_Automatic: 0 - m_BuildTarget: iOSSupport m_APIs: 10000000 m_Automatic: 1 @@ -448,6 +546,7 @@ PlayerSettings: m_BuildTargetGroupLightmapEncodingQuality: [] m_BuildTargetGroupLightmapSettings: [] m_BuildTargetNormalMapEncoding: [] + m_BuildTargetDefaultTextureCompressionFormat: [] playModeTestRunnerEnabled: 0 runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 @@ -466,6 +565,7 @@ PlayerSettings: switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 switchUseGOLDLinker: 0 + switchLTOSetting: 0 switchApplicationID: 0x01004b9000490000 switchNSODependencies: switchTitleNames_0: @@ -669,7 +769,6 @@ PlayerSettings: ps4videoRecordingFeaturesUsed: 0 ps4contentSearchFeaturesUsed: 0 ps4CompatibilityPS5: 0 - ps4AllowPS5Detection: 0 ps4GPU800MHz: 1 ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] @@ -706,7 +805,6 @@ PlayerSettings: suppressCommonWarnings: 1 allowUnsafeCode: 1 useDeterministicCompilation: 1 - useReferenceAssemblies: 1 enableRoslynAnalyzers: 1 additionalIl2CppArgs: scriptingRuntimeVersion: 1 @@ -796,4 +894,6 @@ PlayerSettings: organizationId: cloudEnabled: 0 legacyClampBlendShapeWeights: 0 + playerDataPath: + forceSRGBBlit: 1 virtualTexturingSupportEnabled: 0 diff --git a/samples/ChatApp/ChatApp.Unity/ProjectSettings/ProjectVersion.txt b/samples/ChatApp/ChatApp.Unity/ProjectSettings/ProjectVersion.txt index 02057f267..3384268eb 100644 --- a/samples/ChatApp/ChatApp.Unity/ProjectSettings/ProjectVersion.txt +++ b/samples/ChatApp/ChatApp.Unity/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2020.3.33f1 -m_EditorVersionWithRevision: 2020.3.33f1 (915a7af8b0d5) +m_EditorVersion: 2021.3.0f1 +m_EditorVersionWithRevision: 2021.3.0f1 (6eacc8284459) diff --git a/samples/ChatApp/ChatApp.Unity/ProjectSettings/SceneTemplateSettings.json b/samples/ChatApp/ChatApp.Unity/ProjectSettings/SceneTemplateSettings.json new file mode 100644 index 000000000..6f3e60fd8 --- /dev/null +++ b/samples/ChatApp/ChatApp.Unity/ProjectSettings/SceneTemplateSettings.json @@ -0,0 +1,167 @@ +{ + "templatePinStates": [], + "dependencyTypeInfos": [ + { + "userAdded": false, + "type": "UnityEngine.AnimationClip", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.Animations.AnimatorController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.AnimatorOverrideController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.Audio.AudioMixerController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.ComputeShader", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Cubemap", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.GameObject", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.LightingDataAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": false + }, + { + "userAdded": false, + "type": "UnityEngine.LightingSettings", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Material", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.MonoScript", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicMaterial", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicsMaterial2D", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.VolumeProfile", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.SceneAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": false + }, + { + "userAdded": false, + "type": "UnityEngine.Shader", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.ShaderVariantCollection", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Texture", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Texture2D", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Timeline.TimelineAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + } + ], + "defaultDependencyTypeInfo": { + "userAdded": false, + "type": "", + "ignore": false, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + "newSceneOverride": 0 +} \ No newline at end of file diff --git a/samples/ChatApp/ChatApp.Unity/ProjectSettings/boot.config b/samples/ChatApp/ChatApp.Unity/ProjectSettings/boot.config new file mode 100644 index 000000000..e69de29bb From 6571ec21fc46d60113b668df5b68a43a8509ed2b Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 19 Oct 2023 11:17:30 +0900 Subject: [PATCH 49/66] Use MagicOnion.Client.SourceGenerator.Unity --- Directory.Build.props | 6 + .../ChatApp.Shared/ChatApp.Shared.csproj | 24 +- ...gicOnion.Client.SourceGenerator.Unity.meta | 8 + ...agicOnion.Client.SourceGenerator.Unity.dll | Bin 0 -> 139776 bytes ...nion.Client.SourceGenerator.Unity.dll.meta | 88 +++++ .../Scripts/Generated/MagicOnion.Generated.cs | 355 ------------------ .../Generated/MagicOnion.Generated.cs.meta | 11 - .../Assets/Scripts/InitialSettings.cs | 6 +- 8 files changed, 108 insertions(+), 390 deletions(-) create mode 100644 samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity.meta create mode 100644 samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll create mode 100644 samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll.meta delete mode 100644 samples/ChatApp/ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs delete mode 100644 samples/ChatApp/ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs.meta diff --git a/Directory.Build.props b/Directory.Build.props index a1759a12e..025032138 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -31,4 +31,10 @@ + + + + $(MSBuildThisFileDirectory) + $(RepoRoot)=. + diff --git a/samples/ChatApp/ChatApp.Shared/ChatApp.Shared.csproj b/samples/ChatApp/ChatApp.Shared/ChatApp.Shared.csproj index 0c0b0a895..076b1e250 100644 --- a/samples/ChatApp/ChatApp.Shared/ChatApp.Shared.csproj +++ b/samples/ChatApp/ChatApp.Shared/ChatApp.Shared.csproj @@ -18,7 +18,7 @@ - + @@ -29,26 +29,4 @@ - - - <_MagicOnionGeneratorArguments>-i ./ChatApp.Shared.csproj -o ../ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs - - - - - - diff --git a/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity.meta b/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity.meta new file mode 100644 index 000000000..d08c2e13b --- /dev/null +++ b/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 593eb477f7a9c214d84196026c0e8b13 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll b/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll new file mode 100644 index 0000000000000000000000000000000000000000..0bc320e35978b2be4d9794e158a4561d8ef7593b GIT binary patch literal 139776 zcmce<2Ygh;`Zqpv&gN`MA$51tNPr}qWH*6OL+GJfK|nx7ihzLV;#oi?CI&&&D~Kp! zZzy&V>|j@HSW&Fkf?lszul*<9YsLTfd1iL^1hD-6@B4Z812glT=b2}odFGjN=9CD-; zg$Nr$_*Cu_eUL6kdI(}6vN??;=}o^xEZUICECTJCeipIPzf`OtW#P9Fau25jJ%6Wc70Nnj zGwh=))&huNcO@(JFzf(yiiZ)@^sxPi3O`a8 ziXDku8>C3TFS%kHV>msh|KJ2I#fN0YJ$H$Zb6Q zx8HtyKP%VV8-!mM$1n>7-mMW5ZfA($;(=cTvV|CFI2a`hop}gi{lEj`(Oggm8ir#| zd^!XNEKkeH(9*Q_S~Gy-jbOAfwMJ~riIH@}o5oe6Y;kvw*ov|kxjCk%gRo~prHov| zJ_@n@6N1X-fhZkl#_Sw0tbIAo1V?&oFld>PLVs)s5_v8$IUf5MaQI_bBLcM_ydUsK z0l016*id3li&W>N#hQ?;Y#v4#R`YO*ys4UUELiwxhyf$ZdFlO(oV2JHP+JMTS3-6g zEGlP-0GfmJ64B>&wFSvT8;^nmVH!e_5hUG{>j~N;DV3Is`3{MqIxEYQKQ34k9}N^Z zAm12W)INw3R-|{XWgkpQZ?4xq1PSFw=;mlqjxTm7k^DLSXeM`QO&rJ_QM}x zdvrjKy#xvej2OBtK<)%D2&6ac1QjC}V<13F(Xoj0$R5-Id7d0k6yqmUmllFom_Zt; zjn_~K)5cNNJsqgFBhdOJ>IHOr5*-woZ^c@nL8ZGE>Y#hpnbK>+B7r<#uFrOmSd4L`rp$UwnJ{QT`H1srq8FlJ!=}00(z4=< zz(ghspcc4Cpmr_PI0cEu6JffVgN*p804>xgZA98r*wn@z#_1H>r-1?cbq1!#UP`c! zhITWdr6^KO5P`?g= z5i?=$`01!LU^x?VFdw%dU1d3^Cewyx9}f#e{Z?5y`6H-hEjkgaB6Ud?>_U@!j_I@| zOPU6a4l8yB6*8U6-Gu2b!aHsP9FMlNdxPkGgXJrgOea4#p&kUo1GV5#O&!)wIE)p< zwLw(}VUk-U_Oj?a{@HC%LfI|049W89i4!*-rE|$`o9q`m zi?VBuH5Ye*n$b+d+(-#kv)aF#0wZeQx=rr6*h-X+j&jv*atEsXZg#4Allw6ScMn8E zcB+1pyEAqU@^QIvxwiB;_}p}~eOwy*p0$i@n1xKT*0>r6o!=eG!>#HmN^8NMBH^ZW zuT)Y4&LxTP7UE;~;RG_M1ZQvp8B~@tI8oHvlQ3Tc4MD5jepQ$3xb}V(!%+D%zrvUn z9pG2?-=LW39FY`-CS!0bSE+#J?Of#~HycJeU19AFV(iOyY&W~v;KA)Y3gePJ>M+Bs z%QT`s!z4$vVD7{^k@T(epqmlHq+`WaA*r2cHRZA)W9K88aH2JwO;(Iu;L2{}Y_g^D zL`(_hV(JoAEA5YF!xr>|LetFXQL09h>$TUSI6NvSbbkn+3PsY*@m$=F4dAJQI3 zwVK?a?19|Gjz%2g)~ea0rZGdwQ~sl5C?`_o*pq7J=uVjcry{E#0Y4wMhoUvPkbG;OSev^v>NHu)wFg-`{sBS*oaM!)2`am5>#?3c;ThbxQKE)xhuwu#lXzR8j16p`Pu< zekyv*e)vZcLcbSc^Z+@H9aL1QVJoZb_@2*e(ag`?%Ry*q>>w`f(+D^5xbs} znaWn7)dN&rnH%i8!Izii&B=_tNhP?hOjli5uDUW(b!DKg487BDh1a+pZ8ml84XCfO zjVQK{_O*TlxZWv2#o~22-ZnCLyo#a5_;o7%hT)8bEloZyaV8+iICc{xIgJ;0k!?YfItBL!B_h@r;0;-F*p#dv8+=@K_a&&;9E?kBAovo74U{8r+ba_=k@qEHYa&FD?pFYIcSadmL<)wPsbY#(n}x+Q>hNn9m#O>|&1;bPk#m-;P}D2QP<7xK>=o z(gbHeh5XtQ%jsJn7V13bP^8(JnbUG6D%y1LJ99&B8cNKf(dQtjO}CsAinMsk`LskQ zUDHQ;WU7}Zj|{7HHM$t~asE{&7H+5v`P7v04+z>&8Fq$tquj!FxkXN&?vz{Xv!7wM z66bu%ph2%qsmA#g?+3h5%d1AY<-7tWZi#Dh$!x%cEBtD9@mOW)33ZD5usWE~d0I*6 zvzoIDk^MHc_bPNtOwo#*olGlkU!=s@(U&BZ9-v4^=M|=v`Ed@Rno<^UhBUNmi<%!B zr_k|>>v+O))`4&TE`;%a?Uyiq46YKWQFGSWV%|52vxgkH=}{R#!$sn9(81NpMQ9PC zbt+nq$U~ErRWs6zZA9$IMlG0p+>_k1v~!_On)mnpNHc8cuZ3ZUk42qMZc>hzt(lTd zA>S|VZi$}|7ty#<8s!gQZ=FusH6oqzR+GBaYF(O`*-t}auXPg5rm!?-cB0sr!y~ch zfCG^;tk@1BG(V3py-HP3oN$LXAspW6jnzN`Pv)@~z*k#l(i&yiFA~UAfM+pYnImb= z{DD+3tO~-Dy|D-+Y^W@977!)nvljbo;}Y&?x?Q5&RyWiEGj}!&q0ZdKiSs{D{pr4_ zr?HN`i70lB^<=lTGx48{^>wHa{A}6YgW6m6C9+V%)#wUu>}8}gtg;RXL%jfA9>%@6 znPDeuFlAr__t5Qb0cf%?hd(bM7s{Lv0t=I8y$iWdp7K2dAzP0sq1f77uP$%fPy=6yNc z6NcfQFcjEt!cg*g3fZ?3Jxv_4&orTH&YhU_IP?xW&kz&Ekc$)Z{s-d0%atF~x%zyx zyEN6mk0;6+G3YBbVrjtI|?S#5#b{?Q-3c%QY?kW*I z58rq0!m&edbPOF(VDrRrUmf?N`0B*PY74R9oP)S<&OuBDZ);kZuZPi0ag3Kf_^~?U z?3kPnapr{%#}K)enic7+HX>F$jyBPz>{bvFVGB&rZHUw~Qu{``-Gr8}=Hh%&*QDCh z!*s8bw7>RHH1ahoN!mWb~ljXMqLxR=x^CoNQ08ENvyR)Z4#QpMrA zk9mKQ=ZOqFndnHE(#OGEq$Pg9rvHqaS(%vd@F@P`#}cVIDCl1hbd%zoz&cpnUPy~22|9uJCa1Q<{Lh5qAT}5t-g`FQsBrPiY8*{_!@W#&ec2fJjWVg`LJRi zz{3L#13|H3yJ^gLW0z9j^BO{TuDx{UIuNPibs{s;ORodOwC^&J840?msZ}D=pJ7I` zwNgt-sSi<;!pS*Q8`2xQjH*u@o2&pguMC$Umo9$K;S5Zlq<~&HN}N@cn=-=zYEyD; zJawrSspxdA&jl!2tY zOhi_{GgBA_w_IwRpw;+0>MKbumab|-`zeJp0hdxx!^MrI)1_3gTdBy=x~i*B`M=*{ zz4$)xYx~7l)u@M2yLI?*c-(aSPp!jVQ704rNn_dh33}?~j{TMAoU5q=l+$95@+VH4 z&HIMT$Y|%m)5OBe$PjiGbqP99Ob#_CYQ&en_OK8Z&pkt?*7syE!uB|WaE6(oEqEe zTB1sPnU}am^9o#s(D^*B!I^#J>FsTq8vBu1df;o$sjVsR`2W|klsoRb+}EyazpL4& zC8`~r#KN`8EfQypdELEYDcVE76%!uz>^*s@X-pkD|IJNll`!Nz%AJ%4)w=@s7NkFFDOOb8mw%u z!5JwHh~m~D>{PY!4CpR?cKhOOsp3R&7cX)(AcDIZq@!!r#>OxT@d0N6!XiEU7;e|Z zRZOZoDj z+xtsxiSr6sT{)>EmSGDCm%_;?MrAuk>RH>a%butC4)YQ{e?}9AW2K5-g`#dB`CEHi zEKk{jC@EWHIAI9!IrB+WS7;GnDd_j4KdU+Ny!HZDkU%v@5+yZ9;=qS>qlMbb?#CAu z>CQ>0!Rwrvs3+Z7hot4~No08Wek+C<@1qAGrg6qxE+Zm z%@fKXt*aBNW227g{cKYG6CUtHu{$INysFzP;B5Rm@DOf2zrDC~QsRh`5{KEp{pf97 z)4t@nsggu-mvlQQ-%C6}>tw{9B`=_DYwTZWL#V!+E6aHRHsBi!bPqGh8H#-hRvSxF z0FNc5@*`LtTulE4-Fb+tNbX2y944O7RX@#$HJ7d`>E=YFz?GLei8N>%rcMVqGj%H) z?eOy&PZFISsKnx<*Qu`C@W5ni%7d!2NG-H-@s5!!9)r)>mH=ttb@QxXPY<-;dqFShw8YA;tP{! zoWzDRPU6BDCo$0@g3QF@3UiUD;`!(c*w@~JzQSyB6w;Ov!?qPKRN#=_iob+FjfV`e z4rMSkz*&ePy1-Dkz{|oEtGnP|fe^4-*P=e&NL_%$UTYOO_}3s+wh@KiWQo+)T6QjC zy3_nWAeHvaLh3uD)Z+#<^ii#)+I8yi3;m75rq!c%!lasP>OpP zH1An<9@<*-gkjTlKyA8n6PgqM9vb2m3K~oX?U5`yA6$n0PfEhZ7QGsE5Tq31=|xm< zm==6E#hr~p8p&2ol~IES06X)f8wm|8%p`TBs^mjM{2PV8&ug@vYLRo_n%Yo_pFMJGvwkxg>;L`5j&P zkeuwJgeu26KckBdT%fj#T2Z(Zp0T-|{2ND}0eXo{Z5ku_Wl<$H_5%o^De)f>rIuG- z3~LNpQ?<5yrQrNVZf<{w+)#Jj#ttNjbF>h16{cn=9H=>}Y;XJyR9No(w*lZDEKDXJH)6k1k}EZ0dx?Ca5km(B zqUp|iRKJ=ZVnWg>$=x96ho8!($0YJ%1`|w#t+@73GcFFOFyr2ecE@o?05dL8=mok6 zy_gpF}L#smM^{+JK4GW;<=qV!Ney$V2&`}eyNX7TZZSNb&!1=Q3ZN#h6I^3r@{ObhQV zd13*GXvH}#8ktv>zt^G#E1r(b$~MZi!-)pwd42qzL2=JQysbnbJC;PIq9lZIsVXOJjM9&pS8lL z9wFfxKyvxb8_Rg@2H3K%%1e9o=y9HlXw4W z@b*+wy~*oD&q_6;m@%4H_%2Ko??wEJ%TUN!c&O_>mrOI(0SX!PzFEMA`vju&ETFk) zAm(TrE@;&>(UXGtSU>Qn4QJ3(^_cJY8EEALQRs?g1@CH-f=VZ)i>f}J4e9*sK30ul ze$^D?!=$xBM5r7F;bU-GyxL`Bq*#dHlveyTO2;0hWDX>7ndK;h`f}p0aRIaCMRsF!Lik&ymlk`kJp8WMx8|$wX z9Ro30p4JAa=sA#zrb|UndleOBLqf$gJf*Xbiu9%$>u3t{&F;`K{syY1{m(0?5x%*T zqGk$X4}t>Ud=pW;lzOV1T<$rLT)z1-Q9FWK*+vw*6S-VxV%*W5@fBh$V@9IbU5K#) zfwI|?h7k4S8!2N2lvAXa9hc$NenEE1^H?drI5N@IwYYQatZRo-PGL7-HW0xK?N<$$ zVSuc5zR`dOb8wAH+unW{Wk{wxN7aYdQk^$kHCRsF1=`VSM}xK^i6%9i1qq>cHMqoO zwv$cOgc1%qHvD^q;JrNye~$(B%`iF0kO!gvc9Ix9cl!;ukV~ zwRu>jFo>7*S$rSPX}hUz@N!k#0%b|t(kIxwwuz`kNbiShoYZN_Ny_|%?CSw*Ft>1c+_ zOkRtofs5gt7++5qv2yr%>+`7AHBxrc0O-U6fG9RD7bA51L(jUWiDTg~^fUN~Hab?t zp}I!4wKEI#8Lcn0m-s44?9390Vq=X`nN#}8Js`{$>0o5AcKT)1}88#rU_h= zi5?i|hI2le6zc-*@$f^V;XILmc)~qmIA0}ThA&!TIME9=Gxlqlrsehd;{bQ1_-A%v- zFiH52n~<3#s8;~7%J2Ka7S?n9!WQjAPE=|MdTJk=ZETF&y{}aPdm7EuL$OLE6Yp!O zZ0e^2WK(Y)Ae;J3W%FxXL&!H-7uebqFf0G?9@i;m6pKG;Vsfb7UD$hAHSZ@5Jh&d^*-Ex@ZzWIpxRTMr z9{D%jne@&f^&P!)NL_^$7@tp}L`{+XHr4QNRfDOXe>P3riJ(`(vZd*IoYB_`t91M^W1Z9wwJ@nyNmOG4{gVB%@wO(gbOAEG+GMz3rmO6p2IVDfEQ zbDtSFig}1;UY;WC>F|o^v2O8iw-^6WN<2|g;?q4&$whR)ojh3|m&SLm^`SUzgvK?j zLZ`DuV%QO&ziES(YsBz`QXpF5@u{;2B?9YO03rm=%g03~c}iB#!R1zE&}b&B&`iz= zWl%4#J20w#irg&G_ah6PHYkPL)tLK>S+2Tmo)GLAo4?nDiPPZ;QIvh#$aHn1)uzwe3IwW&!J(j1Ns$qGRm*e5%8-oQXNl}RL2L* z=%W3cYUX}UHP-D^AGDYKWlAudfB+aLFJV#UU4dJIfUC!#Wk;w|Tr$y_4-N1b`XJDVQw^*Ru}_c@?cO~sGZbzm1trC>U>%U2cM2u{kzl`Os~GmKPCQ=fXl1K?k) zBBT}_KEd+0}y;xITogeW%7J0dm? z9U}4JpwuLv=@|qo91WA>;g{qyJ@DY!C_`fmYZb@G>v%53w12$;<>;4mYbt>eK?Mv? zEA9{}fBhDTy_RJ_8*~!1AqsslDPrTYJ7Tte*Phc$oPC*-DD=Igh>eYM#KtTaX(2s~ zv{sxZy2bmbPy-htij9RJV#A9gEv#=7KSt!tK=;J^foo|Wqj;uKRy=FEG1;6^Q|DYo zl%HULrSw^ac~pm|WjI3f0$B|e3@pn3=!~T8X?s{+jdQud&a|faL0YBD(!`~#K__9RhC~+7FeBcM074uCz zrI*@}j|Y`buv}kII1*XB{iJn>HWl>K`*Do_cKh)*7}sbfL&cUMnb?o3Y%*87>_&8w zvRtfR>jWwL@k27d*?r0*)E-b!4$zotg>5{Of(($^MG0m2wNmFk#dG!s;BKpV}J zHzoEM)PW`^k|w7SSE5awO;3CnHL@R=BwwGxj_zr1r7&Y^DP zJBu!2O-Duf3z;LG+xDw@CDn{;la#ssu;wFOHPdZlzU)YRME8LSW>I6Nqp9wk|3Tw>RQ5hG;)1ufj#=7&%O2YtSlZAcg) z&J6|LTbAPS*}E~7^g9be@V??lNGslOf|rh167m#7F!pbneQ0am@+iqI`<0m^)kZU6 z-l*fn8YQSOAqY2OMS@i`7D7br4rM$epN0ACPawPsy3jV)UCA#jr~yMo7_N$19wQZu zW{OmeMTr_Q)=;A=r#alZKhC=UtaP`HX2SX+!^qLHinXlw#~EdcQ}eOv&#NAW>MSc? z>7tB442|RQ*tY6^-MnDneSBV9E7TOlM_?c-fGX zCo&h`1SAgnD5@Dthpsk8fE6v}51Qg0DjidDR&BuRj~xuwsz^`brBiCfTan=PC$egD zz>D2kpw@?PJaHk^b0}r3fl8EUoB@xB??8!4uiXcOIQ9soEtP(V(q?QMB6V+h2pW@# zHYdKr_coTr1McsiK#@P$-=6?k^wax$@8t^-H7$vz#! zq)FEXDxb75*|k-E$WEzavWL@!Nb=g?IkL|CiDirH;Q@p1tWk4YC_tK|worgHHLQh) z3cfNq39=aI^|3Dg0wlIQ4W8th8N~A(ChZE}q)GN42x^j9yOLR0Szjg+c9G9>tRu2V3bE_DJKX6!ihD1S({FFE~D$i%nT4#KxJ zapi)~Zsz#7Ol^ae?&boxedgr73X%gD_L z*)xdBjmhK&+H2lHY2IOf&F^WixtHum z_dlvZ;7fCug!`=Yx;F z->?z!0Pa7Wa{W&K#b-iVdN9#{^eNS3|7AwT_*L)WQIcfurR7@qTCjx9Q6KdJF8%`e zI3IcsmovKeyvhdNqz&+p7tD_}4H@eIO0Y4)? zi+YUD%$zMW9nEH(cLlbd$0N}Aal)Z1llUwoozGMF_^W`QL!kM)T@8E@0*%wJ0X_qP z#=dKT=OfVgW5P#Xm&6|+=?vYF#9NVc%C1l1bCGnON#VXX0H20H%lndW@x~-R1xYu) zX&?OdJ~;En_WZ;4!Oi>Nd-uWL60W`}S^pX&-T1kEaN5o7>BIKH%lE-g?SuWdxXZV^ z2A4^GR^B-r#0~T{$UqC`C~P}(_02CusSG(=hy(9i{GH=MC+$|g%jI;EmdTDv|EYP>BrZJeA0F9#n}e=N~H3!O6LuOJzGlRU*e} zp@dTPbyl?~p{i0bq*V-S6$`bBMOwvTtzwB*u~e(rF`=P9p|3a zo)W6b7_o^%&Z5>=0q7Ez`jTSmI*Q3I6caN}U*4iMih1keyD5#8iRg)IJhez2#V-Qv zdk0V5v+FNn)N$R;Tbkk#zds zm84&cr1N#buLDK2_OcLLOq?7k-60bqh`89=`p9B63fv*4f9l#$V(0Kmyz`GD=%yao+ zFC;O~{o7NR=l;eQlXPBd9#3IjYa%Zt>AbdVOkrMIieFCBd2QH`!n`(QzmlY%iKO#J z3J=-|ya9pMm)Dx2SCjZmB%Mtu%xjDFT9VFdiwpDG;=;VPxG=9RF3f9-3-j9I!o0S) zFt07sQ}y%O;=;VPxG=9RF3f9-3-j9I!o0S)Ft061-12wKFGg9f#JsHL`H-Gg!+I%6 z&C6;@Ni892X(`q7bjQS;>(>)DmJq$Dq$g(KjKtiX>1;=5`~#N6##LiD1N zo0zimoQ}KnynL)m6gZcwM9|r-5+SGJb>;~>b5)|yxmhKOoKIDv*sD+CS(T`Aeo=|8&hWRmxb2*y z64i-irY5n>L=wwP)Y+_fYMrlCqAsz_baSF_vz+eET$QMIu2hL0i4~})^9JRp73f{+ zT(xu*wPM%ID-HEHtvE!amE{vGGs(Cv{tsGpn71zeIi=szd^7391=m1)ne;m=5XA1* z;yNw#;3HK+>AA_|&pEZC7WcjRJz$K_qs?p^QEZ&h zL~5|jUx$1fw{viXdQl>&?!?pm{%N!j;%BPwj9v|n)_=Aa{2%1ecVQuzD0U+RoAfa$ zs}(13ZWaEU;v@=ls;Z#J6^Y7Ceqo$d`U}L)W{6J_=^B*m8gGOg*I_MA7-1|vto;H> z+W*seEpGDa^IBrSdF?M#LVY||xMwMjUVp*SYdCrIx)%a*^!h7B`kJXs7@ZPlt$Cur zPMo#keyc~NQ`IM3 z3`|##Jzq!JssP`*S7(}EQ&Ak8QrXDyMl)ePe58-aQNJp-Zf5m7r$Orl*ULBHiQ%0euC_$SatfDpqHt>&g>P^;m2(d3NI55!Qutsg$vL_6H2jsF zrbY_?TT0;@r6=~b#CJuMK0A%611NmGocLe2C|$y(Mwc2@mgwEls0xT%%UAafi2rt@ zaLy14e?Vx7y=kxbmWv(T=%i>bYGhJl01%|FAED{vSbdu1K>E3I@b2 z1w`#$P1Nrp!4l6P42a*r9}rCgSNFc2Wd=kyn|MCAh&m^asF$X8|o-LcqoORrmgP%o7Q{`YyJUp(xqz4Ekmg- z=W;C%L`dd&Hq~;ym%>@BZ3}DCg(c5Ki!5LK_33axmr0?s!9wfOwbN7-xBw5jf>DmOZ4kUJ~O$7(oP!5 zf1Yhp#&&*~d--;I>tIX#Pvqh1fY=oznK>Z}Z)~9OL=OMM`FC-64(Ie{o<5u|QGl6a38*Hz7?eUEMoNoS%1b6xt3X zofk6a-Q1!=SdT{IKn{7v!IXMV>FVA?F=jDRfx2UC5~4XGTXaER5yHR++J(_O6qGbZ z4`Vb91;r9R&}PA|<1hnw8CAk|L`&2i(wO3cfemooQ<{O`!=I)iZ4^OX)!G9-v&$vJ=t1 z4)g>m&`6DXF&bE|XuTQT+)<%EjJ{@+O?Nv{ZV{Kurh8F9C5&?Dq#5WuM!7UM0(EAT zFPaz`8VzH#mQew{#Uhh^aYsE<{<>&?~*BxjX%I#&Dy~LSp z-JN}I>pcZe7q4J+mqzC>YOpS z9IX}E!q(_QM&mTPl+jv^E@wSUhp2KJ82!Ms25~c^H#EAN+wf7JmOfL^Lyt15=&R6n zMjnlxX3frs3_>S2h-aDhPQO8DZG(7@W&R4<6#N~#9gJSCCNxa!WYosA5n>mkJVv9$ zn~XLvItcGNQXf^;Q@L^CC$@aNXi)D`i7|j~$QDg~h&Bm`tn_Xz>2kCvVl=I%LZ!@k z4QNw9>%{00M#qRs<}8j9=P~$h56OIzYd=Or8NJJBn&{4GCOD^v<3wLZy;-waqCcZw zxqY+65V;&)u(DRbbLNQ=j7Gz~35{$=8->5moGtFdtUDggCT_&}JaA=Sa58y+rGju+n|Z2`^wPJs@sl zOXM);R&fWnD0e8;@Pv54Rqko=Jaf`B3RA?3;x$If)~|>+xZLTi*{k9$SGhOwgfsP+ zqP-*j;iA1K{>`*%u5Y*a%0>G~e9JX_jcbf4;@{XBrrPi=E)1$feXj>{tHk+T9zqzd zel)j}IJgUin{uB(_^Y47y@4n$Tw1fDRwwaXI)xV^lwxSs)44~s^=*t=N4EXkK=}o^ z&w)RZ`82{T4!7h`jytU+sGP5IRjC&tXGedM6Bc*WictP3oSxrAX&-a` zlXDhUP|ox!3STOuaAcUmW`v!@%h@}j!_1){Alil=fvLC&Q)pXXZEk-kTv z!>JYDAY6g4lW6Hc;oWFsCvhf9)r%8zKSz34-S-HOWjPCTenR?)Tu)vf5iQ9=_*gN8 zpK_SaIp_AHoVIET`&4G-brK=2-J6kz^gOoG!I`AhWgWuE8I|1`VLzsR(IM(e_d)u& z4nq)5EE<7OwM9wmo_i2-p2?)X+r?!UAxyOE%cco=N47oOg~B^He38TNqZ3f7YlkTa zcLXRjIDM<1(wF6vR(G%x=6MKj6&E91V_chOi2>EOG0$eE-ixq@cnbM5hrWie6Zh|u zy0=iv{EA0&N!okhiOY|;)b~h#j&xAm@A(KkTLM2J9M$1Bgctig`6^AN{P{ubS+epe z9YVT?C_#8Dhucg_H%bZzc_@r?`V^1i?~0rrB8u=<4!4<6meYWoXXQZDQkp?_9>X@Q zP>>pswTo`j*2ZIegAf{iry9kLNz-{Gvmjyn3O`NQPFN8}&b)~%94PXUD+8Y#TBp28{qBk~iT(;J?4WZQQfo@Y~fbJGae^M|gJ zxQ(;W#>vLKd`nafI3iz)silwRO7ZxhygVs}pcR-mx;&k0iPJdj)tmCmtR>)_>!tL4 z-X*X=-<&pt71?JYOylsm4r^HcWstwkyc*#s>lTDrY4;%9U_FX(jj;pam&Ti@{d@ak zgbSNKL)hy5s$EXK_&D$*B)^-r7vb62-hxhI28SCFQjd2iAV0}Rc)usVV1It%DFd~U zc?N-pJiG$oogL~}LIbF0S_2Wr<>3fNduJegnZr{&aipt_vk-poxuoDgR{E+0y(2zD zn6OVbScdAo0i`<0TM$-y?m;-udbD6{IhJ6tG90d_UH;^DXnGR;9W|YrM7x2`P9mbM zPogwP*+@u|%uhgjl4;9;(r`ua0;Bc5zJtFg@Q7U+W#kchmyld9h7SG~=u3@yei19cFE z3i+Z{or2jSN(ikTQBehS3DZ>n<%(;PC>wv_Y?DI1XAABWdE!2eM&hp$0E!4jNH8tmg{xXzV1)k|-OTb()iUr8Cz5gmt^)ugi|mG?Ljx9Gav_povL@ zYj&|PiADu0#7bRm&Cok>&3(Q`;~NhPR*CgVPKoQuYZ-kakLWT!*j4PD>b@#$Y;S3;(U#^5BVDC5{=Rteh7{f*JzZ}uoviNMo$Zx3r2}O zjFyRDKW}K1ScI!E%mu#RnzBNpMVm(70Uab(F;X+iA>u2IXy!Xa`0A(}%{}4Jp<*$k zm16RMve04TN`+vvZlNQ@Rz}8TLg zCAD_4c$yKlc0y>1cvYkCfQ}ZQGE%LbDh|T&4$bA%+Nol)LTK%=p<~5!8cFd(aGKc3 zXa!n3J2XxF%7`qnAT(Wsa4ZDh4R@>`opzjvGFmSNm!29rPL$&yi2QnE=x%Ymn9OLs z__1(JXr5T1(Ib^thZcxk8kJYy96CvOa3xN&cX{=e&_dB&qaC4bAxA7sqQ^sV@sUQW z3!V)v5_^*9#n56w57?5F^q#MUmWcTp%^CRj(5YgDMz`nvGqjZ0@OwJV%KIYJEFRD_ zEAKy{7O@LQRBAj(afW!8(I=8P&k#Q{S}TqZitsX#f$Mu}?R`xmyj-+tbWWWJpCvBk zBm1=iLnC~)xSWw%bIuhvFj|jC{sQ511%_F&zVk!|BURsdqMDJaZ?zbp5!JUwysgo@ zb%o)z;tP#pwT0me1^&buYu2fMVfZ330oV7WC+V_I9LY%OvR)jkknc?R;CeAfqsRJ| zhu4dfG|KBA0a~Kbgt|UJtqQ?I1_0ftka&IYo%q{9_b{UNjSF8UDu$@qcSWa%uMoX7 zIzBi*e3e+MQE>45@HJw)M&*t3!`F!gLshxPqDA5Bao()Z*!o4`8$_f@q0fLeiXj?x z=&>k#qquUIqWxI1D14KcJc5vF?ag93Bhsune6x6q(OR)9`nT|{;!}-|53UQ}E=G)0 zQi6lmg*S;)HOg#U7v3yJj8e2;dR!g8OH9^iZ2i^YyTxM~tsZc7_#UxhwBi&!HiqvN z6$dNy-$7T0?-vUXQRp8)4~T|C2`N3diXn{F3t#CS;jQ9XjXo*3BfL%QK8!fmi(Nnu ziXRSFC@pwT_#x4KoI)=Rx+naIz~4J#&Z%7<3qK}q*XYvVW8ufekRufBvBDR^I49BQ zrtk~lCy9XH)0vkPy%ydseB%kJ@xEO&O(3+=Hx_gGc5#qK!#1HyY?YO`}z9 zr}(Ev)b^d?OO0kU9#yzge6P`x#+jfQM{*m);F{OMJ4H{0e780cZIDJ!RXhbWQlkwe z#Ce!TCt=63Q%ut6>|#PQH2ScJq@1GBS$MKwr#Mri>SB_ziVCoB)sXr1rI zqOhFIXuarNdS_9gyoZt6T@*|8qO{sw6w6a)lb*D@*j7{`muvJLP)B(wBelCImpOBY zQ}tN6ELRABhcd{Jk)g%Ry8b^?9Ih;|om6?Ks$gXW&=dwx;WHG$GT_x+Cx zUDxz$QB8uDd3w}ej3)tfxx;$qxlmO*^b(_tj$}5<4>heCGfJcUOw*`_Mj2SZ zZSYeKjWUN3wV_LKqwJ$;BxR5s#OOo+Fq9i4M`&~#$_qiCsf^Z&!9DvI50&pH(U{^U`Aw2@Qt>eP!%1vU->g2fi}AQnOrfjl7XtY-dZ1r< zc(}~gh;}T)WmqA!p&6XdGFmSls~Md(O1`a8ZP6vgqvXFdS_#@1`CYQyRmEdu_Cl&p zjnqSA38R(1A7JZ4WQ9g0*s~uZYc-YFCbIMtvyr^$3i z%f))rDw!s8HJT`LOQy>r7v~JwS<@c1tdbeByNfncHfUOf`E~J3IVnjiDLGE6Cw@MW zwWXN$ zj;vs`T;z*Aen<9kamHnni!&|{(wzOp_>#ChUZcB#7Rf~#J!y_FSu9W2Xo?(PvP7P% z(Nxd)l2hbbjZO#cRC%>VZJs^;)8uAGO3$V8Ax5gFm&)y$^E7c($x`{DM(+TfF8{01 zzs;jcTIFwyl$17^zBuJCZ8DG1a`CF1S<)u^DVi@T6wHS|LsC(wni7&gcfKNt|AoI=-(BDmTDBJB(zMUt^*03 z!$|eYS~>g_(ky|-GEzOgR!(NLT+B2cN4e=P+J$nirVTZBlw2s6Bxz~lB6$I$4`mTX z>N*)cm1_7<-Y|G3Q1_*TmWdkN7hNY0(Wuc&Xs$+&GdhdWhyL!(P2IQS#qfiYc#9JH$a^r;UFi+7mJzKMy?|yjQoXrRp2|q|^hUX&9c>k(m%f(q< zr}TEYjFIBJL$1=aX7jYtJLK49#7WmjQf!jnuOPJEH?rW&(oOOgMxXd;SGh@g&LY|; ze%e)Tk{KG&u5y#i*NAqNn`8+iWr+J2V|F;X?$ zCGkfn@LMjn$g5HAV2#eRZZExC&eiBz&$iNgyD` z_sgJ0dp#eQJ|Md=qWaRrRyl-`nl-k`OEscdW1D>Fe3GJOjcxKRjcC@`CckH-=80|c zSA}?<*d{$|sN9EsnkTl&422}k6A#M6HKKXqAvuYWvi!sHI7Z4656cr6Ef*2_W$D8* zu2DD7p3+BTvqo|2=TdrVSc*fsWM>Am6T&avPYa&Pfu1p z?<4-x>M7jPm3XMsfolAwkfT%5kTq zxP!;F3fFTf6?QBln^2FNq6+haM-1XwqKtiM3y%eAg&~xcZesqx=2olORr&m>7!iiJna4#covC-qfT$k$80Ax1ioLLd@IzgdNgcA3A!u7?tM@{Li2)p5}1xmk-u($Y-)3+ET|8ayzi?@0mH>J-Ij^ZjAyXx|CagvX1M+`Tw74tP9{CI zQO#k!Ij{fSVhcY_w}qePpd8%u1m|w?xD3~SD!vsL_5DiBLJp;`sopDo#PcSNvY+{W z(-8Tih*nRL3s7TBE@Dki7lqb3dAg|fUMh#0r&L`juag~m-6mJCgfV7#;A7w<%~y#? za5w(OCrKV-jv4T)9A}>1)XBJ#C0xl8Zs4}u&XVup^h2E9&OFP7j_blYpZ%cV}1=X72qu9MF+<(SLlHLxTi+HptChASxDKz(RU0YbU%Vc^#zsDmiE_@ja%bfOo}uQwkw-lB#)7IBJ=aN3 z@oS#bQP*y~VM;QiEVG2e1+2r5f}X1Sk)NjeQP5LVThZh2L)nz~1=3A<-*G6?ddZ&# zWFcH#5KbGw=>eP`>Qt?uFBu?x0dQoWm`0Ww0Ub7IRI-=(Iza^AP5o!08E`K8DlB zaC(dUu4#7K1TK3FhqG9p1?-255O%h}q@mvjBtFG}*Xdg?E0ktBcH&h4EgslAKj zW^Zq6fs6$ES*OER%ft${)hbS}13;)d0EqXtKNJ(?+&EH1GiewnPmfC zLU=>(*R1R0U41{bZjg<*OMZhSPpg*W3k>fJV{3sA;q`Wwcc)oio$tM!b^g#Kuee=~ z8(i!C&_3UUUj3llbi}qTZXnA<{j$k?u#QV?RA>B-u&l)^AP6et@mDL zbScUf^Ng_rpF()_z%((#Tsrtx?>J9M&&}R@A23fH2TTkyOQW}BGEH>hlhK{g@&3O{Kw&_55lP4QPSXOuZFGv=0Jo-`|i%l*AT z{S@gj1J?ToaC$h0^(I*uc4+vwe~jn(=+}_exnht1I#7T0Z!v}!;xAzj$QUrTY`}oAv5gSeR&2mV!j5A*(l8o{38NW#W@J!^ z+Zk|PlE!Y$jgvY}+CZ>x>$>TUo1|Y!UZJ>coHn;f+q^b6aSH`E$*a>izmj{K+q8NA z|JrBIIcLt94}I9leZL51oqg8+T6^ua*Is+=ea>0Ydbi~2$Jo5BwZATQ+XJnC5b9qz z3dm7VsC&=N$<{~eML&l=(EW3*gOdIsp?MAX|MAu-iG9)HX^0oC-|1pc{WWNKQTpgb ztNUu=xtF=7?vd`_XeB+LY<BbrUzYwUJAgw7sZ)1vS1KvD@1|Cer)3qI1FRTJ`fjBPl;G@Fjt(LW7$= zIPWhc{5JycwH~*ehi>~P}d zX#0;OTrVTBzAm@n3+?rFds@EGK2O4n5Wc3qOW>7A!(RU7+rHm^jf8IyxLF`MzgXQ} zM;h*~BMonFc7|c++_xZ%r!Myc z4y#`P98u2$?o)pXm{jKgC)B?I=2Uw}SRGVv0erVw1DIEv0UuWn0KQK>3iyP24Dc!S zIN;OjEZ{S0WoNVcef2@W&#Pwu@3a`c+hX`0>sJ8>txo{H&H8n~R|WqYA*T7Q5Yv1r z#5A7?{TATwhh7Bye2D2^k~CkGG=Cv!z9RS?b>{dqrSF0xg*Qvh&yjh(E>{I^&c$cb=^r!*V z0r;TW4j2=-Uu7ceU@yK9=~G#h*$4abna-GmV-k)d_DhS82lv@3yW6wcUd0whpPkS=KFSmJ6m=()1zCi;+IT^dZgvyR1*rY!^&a(!?Z9 zOfWH|>FAD0nz*%0eP!_xi9I5*N2G)!68pGCI^QGs6TsiteM0ch3FefPeA@b`8tOhR z_&*W+S;3z}`hDH!1plhwRfuh|Lek#QA^1`1LTqn+=mTp1iiVK1T4K8q`&@Uo#4Zgw3Ky1GMn>Y}brT3z=+_O;+6NP}LMl-+{qmXzI+a=Bnu0YYwp|5kUO;I|7tCb?pE z_>j8t%9zB)1(TQ9BgpmD?jwSKTd4qY(4pZTJWa@|B_(NNcyw&zahZCQ{e}2$>X2w_v)PUQj2myt0XWzOspY-qOT& z^+}pONfVQB%nrYx{^`mif;l3XBPe0@@?(ceO@pHfky;?MDWK2b3!mDC45TY zX~CS9G-m~KPB7;LW3@>Cwg^2f(!YY~7EHHbwg{$AFnxj<7EDxNLEv$Lrv#psG%o?Z z5IJi@)^bi_tybc#R;gEDx4=GuF@Z<$d7NiDk4gB1z>@+`3p^|E9Lo99Vjgyae6|VY z67Ck*E3i*sOkhFa5rM}Ao{(H8@M6=CEq`7xC)=paPD=Qcz|)fEG}4S-^)kXQM9xT> zGZK4N;5kWi4r!LHQ1eKSC9rNDscM4@SMi76 zv%orm5rIqF+1{lR?iP5ZV75rOS74vO;dZuYSi;eEwl^x_7}9@fabCg&2_KR0F@eVg zb3))Lfu{xk62joKgwG28oIn*8I>RipPQvvFzYvK?c&XsKCA>vouVDHlJS;F8UWRwe zswg_g6V0!0&K&@W%yzT<|9ab4uXL0?!CMEATt>rN0&k9|X26AZDqAS4p^c z0cnd0%rBruElBv7gpW)3q=ZjN_>6?lN?3I;z16`IA`)II;a-7Jf%y*VioC=Y1anL< z#{_d+Fee3bO2TIas!ryzI$82kfxS4G_)KS1U_szB=FBVQpccXx=fu|aZ183Auqi6K7QE;k?WX*k4ySf0?!IOFR@k^OO6O!DsW2|N97g?_ja+ysKA22;{s0!e5s4& zpON%uB>h>zTT6tK0=F#rwEDfsaS5LicyAvw76GbRA511{S_ZjzrCXV z3hI_C0l%_%TZEk17NHF@BH@z}Qhr9@dBL2QShbY+`lX`BB)mo7u)w^)V*;O*G|w(& znI{GFl3>&_;fcU4%Y+*e9+vR1g!2NA3FerDPfGZtgwF_6-BOOgZQVkDH|rYiW|_lR z5}p)z{z_`a`sIwhQsB1bA5dRgv28iWMSeNUIVSMgaQh?Tub~G zKuDTkP6{T{BY1)N9@cV9;2DAHI%0;eW15o!&j?i46B7}*Mc}Z&yudR8)f!17@Youb zb5h_Lfod%=5rJC-4hzf+e0(iO(6a(h3g#sVpOLUyCwT>K5x8v~xiKu^V**bKR5wUU zfm;L)3(N~VCh(-dE$c~bUf{9y|4wQJ4sT#MFYuValLF5OR2!vyfm;M_+epfXB|IYG zyo4W@@G%LW6nI8pkJ_@S z&MGY3vT3XJt)<5{N#6-PBT(HW{UUISz`Vd?0?!DH+$>ZH92S@tcuZhqGfUVaFu$28 zj|n^}FnzuVI^j|}d)_u2bZT&yh|L^+VhIGTH8((SsQR9-P z?M*-5^mx<9nqF%9=cbY7_cni_`IY8>XAV4t-^U8WY|{S1q+6T28Yt`}iv_F{PZF2UaK670P$ z!&_ai!tUz|brZaQH>+#0BYGY7fY)LV_*T^m|KC>Zi1w*F0sGZ<^;UH|-n4gzx(As1 zaQA@PiTCNUjZBQ>Dv!{-zg!dDl%W=eM^K{y$feZ=aR&KP8lZ;4+r~ z>ZOc*|4PEQU&h*XEAG7Z^9Zk6Ot?hC&ondq>+Aj)Fn`S#0e7$aE5NG-{*^!-tD&yt zS1w^Kq4k7*jGJa1`*xwqpX(om=G$&yIr}zz1Ms)k{1f2kH#z*<+Zmx_6p3d>?5x zEdCLo=JqF=Lsyt^_R?mApS*}=W(8h<0u!tip!)wdA7_m(N7|KTlHAgo)lbwfA8`_`@k+#>LA z*W7^cTNmF3SdRadWA|;?j=aCU<{m(&M(%gi;XF($^g{?bp$RYyTnOhq+5j&CE~Ku2 zmIy%?bO2rnEnz_?EJSz(GzHFdAyo+HKrR7(HDCxQMJ@x}2)%*R%g7yqp1^y~peecm zdy$*p>|6nOJ93Ah9aaP01)UOtuDA~H?a(+O^$xWTWex#`pe5EL90d%iy(rt_n;8)v zfllJXtD6u`LoeY>DQd&11VEfD!W$_q=$P9O&Y@vI9Cz_{08U>;iSwM;466RV@UlyG+aoXfsPB|)JYofA3 zORV<;UT%E=@Cxfmz=-urfJ?2TfXl590^ZPYYgzyf)klJaTLUn{PHvc3v<)cR|{|6+X&@PpRh0zPeh9q_}}HvoUxdIj(q>mL9=Vx0y2 z73&<}N3B-@f7SXH;ICQV0X$~?GvIOSyMUjtz6W^1`aa;Z*1rNiXZ-;1zgqtb@Y6V* z6H=eG{vGi5t^WZ01MA12{|^B}>T?$U@Kk_hh13_UI)wjkz!2UG-T?S@s|oObSS^6x zu-X8>X|)5sV$BCUZ*>5^YApo(Cu=d_x2%f*zinLt_%GIFfZwy00RGsz0?-OA#p$bw z&|v6Jl?mM!8dVR~t-;*-j=FV#qjl>6_tk9#d}rMzz+~OcfT_A$AcOxCDIZb)hLn$} z|3u11FsW<=4ApM}tgpWru(6)wcqK+zAI8Z5@*c#=s*gk3f1rk}DeL{#?^@rmzHh}t zlcApry*Kp1(8oh(LO%#K*WFe3hjlO4{axLn`X%*~_3x|ySp9#iZ)&)_VMW8;4SO2i z(eT}dA2u{MZfWdq+}-$K<4EJbHeS{Axu*YYx~cij=KGo_n}4qPcSO^TQaYY4tVhfVwy|rPhU>Q|szJ z$+KMQy2iV#CmMHH&onY>%X@g#qT-w!oaXTtPi(s4E<-@%hsLqR)rp% zw;I2@to`$LSP#y7SUoxKfci~@pPcuy^+)segl=u$6M9?w1EEaop3n>JFI(Sk-yf(${0aNS`sd^4_f_^k_lI#if{Dzq-NC)BiHPY5ra#Rv5IlIc|Z)+^QK zTQ?02t+{^adbN4`cp|qewKbEDj>Mwb-1bM~sobr5O)S$%vcdF@cy3>MWFRq?ismLW zai)=&JL0K$CYo~){i#GQ5ltrE<)BJ)yW?(+4GnEeWG9l*slH@1o0UR^K9V<>zH@T# z?TJjhH#Ks5Ix`l}-JeP1;ydEmY;;U2Sfi8ej33xGm5PohV!fHM$#Jw|aB?E)q}YBi z9-GuuN{-TMHIi&u%L031xpYSOAh)DP0)v^U9nlGCb0WrgjU|<(gcUQcD>lT%Xjcm) zp8c>pK9|hrqB{HcW`PVo@I4{7Vg}@Qtyc8w#7%IlgZqD(d49Vtwb=11bhSw zmbD=-I65B9p~gGo$q8L=G530w-w?~%khz*P&D_ngeIJB|6NRAB+4Q8T`#v!urz7ZwtoJ=O8dz10uHLBlkgMGIv zGZN3lN4&`Gk4#2$cKY5}4uZ~%yW`Q3U8&@hO{R@y+GHXJ?D#}96VJG+fP%u^ozd*R zfp`v~fjClN^o(A$r6K+NAZ5C{zr{`@YFc2E5o2O~J+(8QceTK7y#tw% z656^cB6~+h(0Ldq_i~_)CgLLsap?p7qkYj-EDpuM0dCJeh-CSieM9%96DSmXxpn{0 z(AH>dKcZcNJC4^AW#v4qz= z_a(GPto~@5pTv8jxqW`D%-p-9sr~*ayF9I(!1JNOXm)>AV9kl8#mwi=(VyKlL3I{Q z`r}+fduV4OAiYdD`_38)~4hZlkv^9TG^s~_a{!|{l zx+9v|k42BKQ~GUjFBd-;Kd4us0eOwE`b$NjdQ}{d3;I0k&tW$yAf|Le3rM2JRX_yi zjuaM9qtN;R(RSNwND`2F>trIC>rWYbm?O4)s>-n<A_**uCqu;Kyu?Q35c=j&#JF73S_jiNz}&^zmtrloQLMT$4*c3N9il zrx^7Yn<{ckXtnj8y&%!<0O6_=A?_Q&_1i|K+(0NW)62A^SKdW^p|Cg@5OGz}VkoN- zcf@mCy7#3=?9O9gSL(h*Hj&fC>?9^-;x%qC6W7V@<|^?Axjl~>Q`Tduqy0V@1<|2L zRl%+R>`y(K-j9ppxKRBR;Iz!fK`XD~5?j$9a}PaWn77sL$y6>eF1F#F5N%-4a1Id; zEgLhKF5|31J#^{WBWL@;Ts)P9+R#(mKyC`9c~X>!TR@6!@nn1qGe$rZiL%#lc4zu4 zfYyPVG&iNQQ*J1xrb%0;Kv@(MQdF>v)}+d<9^}OsTdd?B;!n?@ghl6qLYjW$5s@;a z-~cCycA^{?2ixMYWR#!#Ek>};^6QT(qg>@o`7Fk@G*P3@GDSJ+yVPA<^Z*ErQii>P zsU?$H?U0+gPdN&l|mP1v!>T|tK_bvWku#^IUh@keI^j>(}pUr zN0y{cQIbWI+zmyn;Bef_>rU(#$&i-4BT;yiHZ?H0SFTz6%4YOuZHqx-h|%&dw_5%s z2)eZWSxje-2D!IKLov?1zEm04VpHiY0li)!O_~PhK9P08yGDxz(qhnaSP|tJNm7n? z-6|+5!xHoz@mv6Q(zE8Z$>d-z)@MX}7wm~5(pdycb((iBq}y?}CzYL?pjRtC;!mg5 zNu?xWcvVVJrY^I*@ztq&*F`M*!lafKW?aj7_^QofNaDc8A{SgXKUIPI7RuYK^@T&O z;?6b`2irs<8PC`{ z*S6pT5*Qj>QQHs3l9MAcpHjK?rQs@xj>VnoilIH6;EQ)^TYT^2*qE%YjkC76li{Q) zX{-}r+BcZUVSQdK0lsrA(bE~>%8qCZO2`!plcyg}SZwDOGwj-%#o9mT!fZ>&vpdt+ z4W)mkf7D3|fsJ7T9)W@7AP1w|6~3Jgu>RwEsro>3oGW128i#WViZr+!XvfjS*rfKeIMsMM#X%cU)% zC~O5_GgQpKjFUufD7dT@C#pDKJ1F$|Ky);oo7#N(la#W_A#AULoe0fzy=riFH z=j4V$(Kpc3m@S+Lw}Y1Ri07VVm+{f6eZjt4HR3vFp@tsit{0X`=BSHrQo#`yM32M| z?i$teQ6eRJIy(?gj&j$Q!e=I)qQ6#cPsP$B7%iM3p~#EVu+o;FbH9zJTMjz+_7rA! zLyxThSP~m+yIHkRfYxHb76khqMqO40t7PI5L`@K|h`ZydF$BTNU8AE|abrDVqmnuX z8b6cE-k(6Ck@y7Qo=ife_r6ovYgKOgAUvMt);faQVZvnM1Cyhp@RMV1)-nS1g@O=G z=D|)J*_uq_jug=4ErFr~oYXisQSN9L6WL8JvexAamqN#@TrnaEpLAJKcS*_=$)K;RyXfvKJm zqI2SpCZ*-ezWh^{%)W|1RTq^#ymWHI%wj4NFx4SR)i8q4v-^l#5( z((a`FG7MaKa}--$-RA3W9U9WDAlpoxMdfNEirUpAFuLBp&+5`BE!fHtN#>RJJTPJF zGPxJ`C!Owa=%Ge?1;mw-PM$3W?NMm&|7fwn#G<&zGQdD>D{c%(U9oG=eGne3l#2N< zwkJ(u-6v;qV6rGzWx;#^~_sI=}*z+0w^HEsuZ z9PUYHv5jKSEjrd7x-f%yAde(EoUujTIS2tV#G~ZGcv3q~4_b|`RMMI5RlK-mK?v#t zdqnRgViYr11kBj}am+?so8hd}!5FkZGXOte7O4(aPDdC+bk`(i6LC2@3G}QP5Ft55 zKl`%}?Tp7q;H%gfAKN)O?k)^7bz%hT?2PcyiFs?*%R|?pJu=0`UXS8&;eDFMu-#E6 zwo;G+`#oJiho7MBt}3aMEEW{FuE(E!Cnt+gv$qQ|nNE)TvDzvxDOyuk9Q_hogD1@0 za2KzP0+nJs6tD^OMM(?=%a)#^M~z#wYDXfLNoUieIj?K3Z(v_EGhyr_c%&XteZYX9 z+!2!<5DC!Pd?&0_;Is`R+dH`1%WWQ9cje#$P-%f8-AGnEovC+tWzYuf3~OD5HnFcf zNj<3Iq&gDcmL5kl^jcoL4(PpNbM+ZpB~omMwJNf2TbJSz;d|8i4hACjP zGpuX!2|LNn7{3+A*2ImdJtsl+y6P)Q>=aj~b}&_ToNSvF?Q*i%i;B|tqK#e@6ZdAa zt028+L~EYzo`}QmyxluDgD*CS8v5tnB3JrWB76 z=-VQnL=L@obk68hVq|5D-eB>Qxzt7(P2-)xi$h=RuHxu7il0Nt*<5oCBiMG?H=-`G zwn#;3eWOM>l}2p7^#*Ju>`P3Sq=3QdVNV&mN6GYCOJ#d zv;Om?FOEf%maHlsVlYU~qCRA%?zPp@BJN&5>Gc#H;92p#xNgN= z;kw_Q&L*c)E`+1wi+YZ77MQ|TBW2?Q%w$(N+CFt5jJwLQeB6=d`2#&t%|V7NPW0#} zz95*|EWw%yhsgCJRCljglIpvn1iNSCtg~h8MHfv|d5Q~bGF^y$-b@6=gmpLD?m(VO z3XBkMwTZzJ!vD;ciS(4G*CByX#dSzvteFG@BX=aSa=<eOg_t* zIP8_mfjZ8?CU_4vCyF=Yc05M_q>bnKQIb6yX*)eDkKC9r6Be70wH+O-t-`ZrG^zCx zM9UaGhj-#}qMd11NfYK^gKmi30C)EmMZrC|9OJ;TL39a4T`x~r8e>4)N)E~%6>c;J zJqU&~2NSK?wbPq!cER?hgub(T%&gEg67Fsv9$nzW(RrMn^yA0857g*FxwaYc*25Xo zi}C7n+5F0?sE1-^;yP6u3C>-vh%X+LK>r{a`@F~rK30XCd}xq{W(M0h*v?I11ViX1 z;<)VO{GEvD?vl*h{db-hu_Nx7OxUO2U`Wd2uxy|mxs7HA&QaO7;=sj0F>~)&--@Z| zII~lFhM|pP5D%*8CDpR3WH9bT7BevImBA4;BU}22!K9A5=0vnp3i&rqUBbbU^XA zy&AwZ2mb)IZw7vIt{J2;_68735c6gij~w#JSp~wfIp>z$>r5o>GpaHl70-4`saoyZ zQ!Y0w)K;kUl#Sk=dNh$qr|1|f3SCe;?SW8SR-(Ogv8=S8V+yL#&Djdc-XOxr;tI98 ziE}62eCyhwp_qO+3!7M&<9Ff7D*g0{Jh(1W6^!#f;VymGm&V~l$wGgtUa^5!t|NyW z?~+tTwi53-$2eAXgg6F@(|}5z5>|cDY);)x5H(s7qc%$YAVqAAX5(_BCwlQt%l)7{ z$E>AL?ZEMko$-SxR3Ay9IZ?(|?2$N#GZ!;B8Y#EMsRhi@N?aUb&`3EcRWF%>W1KaM z)(jXxwoPWTi#UiqZ!n^nJs3Mp8c%4u9oQyAG1~9rHc8m!dKqVLro(VCapKDne?>rC z8GNzI;tr!Jtz@xp&^`rLT=Sb0#UeeZ$i6P)e8`&+TkMe8dvbrTyd*L&l{^5w zbqb@kctBWeVB1pC;lZ@N!qce(lz{%M4%5rBH9ayV{K9j+a%DeYS%Kxf*`!jvsVRG6 z!gHHbN=~?OW-ty-nI%%N%;b6M8djLHv8j704zD71Ib9x}0fRDU@wbmpAOT*P@(#QX zr3ddcQ4jCHyGq9JK9U&TeUid84aj$rB=F9X6yDu50L&!bMH0jP9fFJFE{d2muD!To zfl;7Nw5i7eh$>(!XDa*Gfh3Qk1Afr}3((F;5|JydEWjG`He~SFNZpidUhq zkO_oXWdyHg@e|0;UN|H&=OM`-L3;jUt-9VU>K(_wD2SZ0Ybi~|8Zvkl3mXyai2!|a&(i{()tJSN*J~@>tc0jUAq1lQY7&&jyj>=ktb*8 zB@Izvu%s0{ImlEA(88`Hm-m7LI!8j%1hq7ZHZkpFu_Rr?xa3R&miC{Q?w&IJa2?7k z-xCj_)Fj%r7i~!5)nzw9?52=|0yPd{+J-hz3Q|ZzEX9?A)`xr2n-Cns%)e4C!;5%^ z0wrh2BRNA=#G9pT6OJaN_CeG{`Q%VZfiOD_O!ZMYy5*|4_d?a#X);zPWbZ< zA}4keke3pnM~0S!YtUQ0pp%?E0B%eoMBYu{N_o2lzfs{BrKYqMly34rV{=u@xh^?a zy4_>)4&+QpZc3R}D}LG|=xIt+rM~y)a*rYJxGx=9o57LtQdgRqH0x2NM;p1K?+?f* z(<6a;fXXi-a>st#YxC3SIBFX$qm)L<33;c(MrRD;^-?%w2F_?H&)~IDERm|#q+tyE zHV3UaiC*hLik0Y5D%!N@G+j#sX`HgOa@HKzG5F9U%48a9j2^t`YP%XlXgyy4M{UIx z?LlvG6iq=6-25%&5nn!93r{CdC;7sWO3jnTza&B&$qvseNyx_F7D4)ISK@guSG70DQmTGw1av^a|%^Jj9Eu+lJ^B z9YMQ``kQl?w}rK6UUG+eoK~ZeLh38dFVsadp<@{&!D$EeU};OJD^sY^*u+_+p*>5C zV03W5UA1y%o=%U>hLgcFe6S^D+V60FCK5zT zb2b#~F=1#iS1pO&JNLNJYe3Gidc8x7l-6JbKdx_b29AnXwYb z3wv`)HECU{E(w}PI7ZZMT(eOl>lLlr+9cPx7SJ}Rkwa6G?hCbv`Q1`?k4QDw74#Sw z_m0+_nkqZzCCs@C8p))hMiQC=TjouvE(_{AH%-%%1v}?<(lqn_w@bM;xP)MvLoMu) zl^K08N!a1EpcOu_y4}_tez}92t8NHCIMX^xHMnYXIm6oBGqhTKANo_<_=D&jy(U+M zj~d67Sxg2SX~tpJjf|XV$1pgfVAcT<5{i#@P0=;tEVm+<{s-_D;|*$!x)G^$T`Q1R zPxox>3gET6q&r5lfy>~yEY(*?h{C)=)Wpo|Upwvksn}*x-;HST8oZ;~w3ka=nm%+d z>g5n!gL*ON<{KBxdeBe|dX%-;m@;nnq-r8vhm<U`)2WimSYY)op)zP{v_q?X9HKPl?o+)ZPb}WUN9q0ES z&CKgW-R-x1D^a43SZ<;Z1x~Em$-}0^AcKyhgk#X{7GZO=8<$Giaoc$rZA6f1qcHBN z=(Q2=ttW`-j`+|?!Mfb0%kVfaIbh55p&Vf0rZIOYnrgs`FCP6**mSCn~O5a zaX}qE)D6P8AF>C2$9}Bf9)Qn$t*w%W@CyAQSRK0o>6N@6zukeu#P3sgJeHiB=}D!q zarT}>hy#k#T0g?2w$v`*?uM{(fY3JJdNGagN|zUOx@DU3j9u1)&oa@c$KgVIos$je zGwF=Cy&E`s6v-j&mt7BDTwmnM9ca&X=&-?QaK=5yl=4H*9^)9U3DnD>t1UMUWj!I% zA|^NJiwx#p#@_EB?RxiRG_cRuBiJyakOw9)ZjlO`$*T5lX$gSemar6^TE zUiG9Ejyn1uZvAU?W2I5(=--)E8&qSk<~Q`{&R+>u1Z#Y75FM7JqtCR%uQI+$C2UYGbSfg)xoG*|!jSr8qiGe%IF+UEd2t=fK`3D^3e zwCJ3m!%A-}&5kzO@^f3F*J)w+UhaAuq;;+-=z%&M5p`W^b4-smZar%I#P50w;(Dpn z%ynPU9q6^8Dp^g2<1>-6+0XcXnSUe4=Nm!qT#nJ%(-$;KW?$;`#zXK}ojnylz2kNE zZJXJc_0HzrdDx6=bM-GdO-u|1TBYL{vs=#v9n7drD+Z;ieKw`bZzejeABHSB$#w5c z*Fr%yP-WZAu@`4X^Xz!lV;jfpX`B#8%bgYaX2jhJLz<`exY02a`ld%6EjBJ0#y|(n zeocY4Rvo%((@EO&UnzbLC$F|!r$<$vaD@l#G(B|ty7@%wdZ{?Nxj96)T6KGPw!J=k zNv+oN^V~~TISR_R!z*3o@|SDDT*zV; zV@)3_ilJ|-%?Y)(gbQzd=#3hcG861H4H}E|z>zLG1WP;FEKFbY>YHB(jywQ0$uax=SQq^?)%vsCIo!srU3(OJw4`BU8)m zPllbe&Q_J!H?=ifuLw+wO0Sh;E9nKV_HoZ7<>s|ov=McGx%}nk#nQQ_T>k0KNx|!b znNV1XkF^c;H-0WF$F=gk7Nk$hl~TU%ykktubR~Wn3C?;fnR4}(r{1x}{!g9(r{C_m z=ryBs)gz`is$I*?ndRs&JD2t`<|_Ovon`&&l(J>y|JVO{^Km&wl^1Y-N2>-7LzOl& zb5v&LA%S}Z#srQCD4i_naAg%8>TS^#qcM2%#8J0MKxUOsW7kUSSc4zJd~c~y;-T{W@uGB z(UkwFdz1!SI$p~r>zUQdZ}|t26?E9L+}w^6c=@BI4W(EAddbfN{nSn=XZ$3To;=X! zMcq&Gtt@I+WvK>Et!im0MZRH~|F}s~sq@@NJEqs={s+JOmRaSl|4{X=_jY!r;@I7O zl6dNdC-nVX&jz|Q(CNK~ZKc;zG33So-P1g85<|#rozUb7-s}jXF!)KV)K>5In9-thss{=!`7?QS6nnFTx{6K?A|x4dotSyC3E7FqJ;>cffTgW=Q_~ z?k5+Cnq77NhTu)P*d%wKP)~dA-w4N-yO}*Wp=MY>Pl(Dtxe7jXbCBCu(WZyWUA=?9 zTq^f)E0@MA1FA5SNGGZb0q@1Q994fX%R3kSl<2rrN7xG=cpC>_>xsWfbsWU;?OT^hsT zQ!b?V3IslmO<}U~-*?MY@O0oE`rethR=wLFFw=5`yPtm1r!&16y@m{)!~Oo=(h@ma zrcehruJG*x)CUWx&8Rqxh4&sZH|FY|uxDEB^rrb*SmW*_Luqhlnb=C5W|WL`W`AzG zv6Sh0)$BL|g3Oodo$08+Aa0m;&$Q22dhml6ret&Va<*2^`OPyvNW&)xg1F&Nt#>vf z^5_juV3a<@uH(zCSq$yws)v=o6vwlv%j?0uL1|5XYu=P9 z_2@N}Rl8O;CQa_jse)rM`5tL71(>T>z}<>tE=4U!#T>#jcR~1I%BrgoxBEmt2~+(! zO8xdR?!xOQEjiexaG0!git(0ho&(~lNIwTduRD#rG>kkx@2k7K_SVfMud6AdYJ4~R zcelrDPE_U&pNoGpIlmHebUmKltWB-3^$IKL+Ws-M_jrh@i+z6xj~+iJ|E|Fruju0| zSM+054nG8sT2orJ2d=zlc*^O2|9OaD(dK?#WrkKByk4p!@&d-GD(!djaL!nXS;H-Y z-cymz1NNM&*cs+5EMN7=<13Y^H+9w43X_^j$Z;Qd&y<=p<*t=`x00$bC3;ttD{Y?E z+D?`KkSVCzH3p+2i>6Y-IkMQ*J@ccAp}yR$ApA502&j-S3qaOy^PX8&Azl6p{Df@QF;m*+UyY zd_N?QM$?;hEr!P^;2`F!ap_sUVaYrxs*jj*Y1)IiueP_rJt&Wf({!RK$!GB&4xG)) z+ZTrRJMB5N+%7<+p;0RphNIP#sN-ngjTU+LeJT&MLvZZ;lBuTLbqJj^9V?zhxScb8 z=Sq1S9$OJDJo_zMRBOsnR9*_>Cd=G!S=|ANnSgIdTWQoR+Fq)q#-LM(v&-#$^lv(4 z1uYzOez(k4+9`ulb|*bl!w{-eTo7~oYr{UwtL6>R?%ECeVIbw-V{S^X{%7@rDy5+6 zH~O-7gEfOG+3P%TuRs)JFnIUQ|5hh&FIIo^(^h+q!!T*ORSXDqMG!L#m0-$cCR}=j z(#}6uiY&d?&wp}%jmr(aRmpd1PrBpaSFgOO!`SF4UC_MoOd#2{)mpky>Yl8F z--c3}gA!JHu)+WG+MrbQ&vF3r)!m%vOPODJN;Dl1tkq0x>6I_+;PbnD%e?MZ@8Z)f zid<^4<5${dhhBG#JUS>CK}~c^`A<)$ zm@e|pnua~4SIt;;e<{B7o?S|-)!8hm%n@C?>I)uJL9;a9lg)Rels@XN@_$)MOzFK> zedq;}aRty7!DUTt;_&4uG>-J(Pd*gljQbeHxkBLa>^qskUde6;5&LH@-8Tnx<5fdA9-FsX0S# zlU*&Iuss;?z+W%))|8y~anH5Xo2-Yk@68C=8s_nHwW(3=taBU5J7v=h4#HP&lI}-3 z0Qp%bngeuA2IUK4wV|fE@m|W<;I-sWa^??eb1;>qQ)^HvcbdDw)iLREo>`!i!Q4&H zBKEF1%lEju7yWL5S|(HSV)}GWZ$(R;On!{ZH4E9(63nT7I)+XV_le6ulHFx;?aVob z?;D#$5A1^p>`ztOlFb+hGgAQcb(=G2rQ;%Kl)2T%8>!H0(?D)&97C=$Cn!(Ll*$_8 zjw=H5M(Uhx@&(BO^9A8+_gSa{o^`k#h5#q4UQ{|_A6e5HxZ0@z)6wSY^}CfX*FF55 z4Rcc-< zN-JUQ%hHAi6*DDmKYmWwd^v3b%7T-YV^49^y6L4#=e~P6rRuGpt{;BnlP8i`Hoq{z zWy5w@aXgvr_|f$?;ml=fuJ~|2xWlE4K4_`GD?uNlqe9<&j;Iwzl*?Uh%eKYDt2+9W zFoNnf~Ldr>pLe}bFAW+L@;ZyczChuuqRXQ;WIQdWzJf zFLyPIBd6)wC~%a|Hc>gHeo>AIdQ>?Eolc(KTwabQT3YT`DAIeYw_EfE%XF>V(t3Di zbUJfwY5u(!7PKn%^ZeYN(%5qMwbg0QWrr7+E5_hwqDyv5S32{=o25y1dEReFeLxe8 zYcn2!qg%@y03QI(d=dR;8p`ywzCuG49`>TD-@Un7$t`3ZmrXCMenoN&s|bEMoNrvv)28z!GQIB! z`}DTb33!JL(9*96m)$LoIZw=cb5=JDjSZ#EP})%1n)2?s!G6AOdNisAt`Jm*ekPt@ ziRO3Ffw|XT&MbLYcdJqh{d0xtptsx8uR~^*V`@W_p69%Ly9d3;2ZbrUrTc*TtOCtz zZwz{Kqk9%4NByZv->x9Lh}ZEw2WEj#O&y}12l+0lT1Uw$S>f_|8vj@nR+H=TnbOkqs&*^i^d3ue(CliNEH)(BSzA{xhz~-iNZh)36?VJ?apTbiOmDz6H z>$KcU8@WUKgr8kvS=20EKDw2I!++~R)ADj9&s3F^4&3$FN^t8$e@ofFy8kL~Ot9r% z?a3A!2QSqo<%e?%zImEIGWV5I40sMfvpTq9E#wq6w|7?9qCfDg6+JBrE(^%4m`I_vLQqQ`OtiWO@q1XQ zi-HYH)ua!;Dtxe5Go0rk)cmbb27GLn7E}sn`R>CVpGi>HdOdoinkth1K>wBo&j8xC z!@>Z2VsVggsEZsW>X|JUI%A0kIXQ;Z9zWMg#bgG2Yv7?6mH((I+%4IBP=>RkTkfYI zoBT`&2Z`>qNsy;kUX@aF-uBABHY4;LWICRTk{X?zp$~SUYrEN)HFz%Wg$~I#SsrJmSEI)Np>MfLW&L+3i ze}8QyxHYZcR&Wom&2Yd6aVxl8T*2w5Jo!!0(gShca#3oH)K<1wyrl}Yt7~tcT3tKM zYIW_DsJiQvT2-s3h0CrWFGJ}^RG2CQ1xGG(Vy-36FxSMlluujQOZwx%o|@KAH}^2M za@11x%&5@HsfdefY5=1XVLx_PYM=IdsLSZ5C{1U_tub-c+hFHdUO9)IDpuPlsJ8<&D&6t z;zg`b^JBBES(_8_nbm%1cD0k2boS4v<-6w2G^fdrCxQKq2~q=EtvQbfQ22}km_|bB zOO9)I3kQnUgMO-l>hR~~0hcObdtf$Y&q8Pe#m3LK;5Hcxc!nYyI8Tk_)WzX#fuCnPJ%i#J5F#1U12;{+P zr%}rl2TfVE$~~QX4P!0Q1NIVAZRbe>9t?8io^?=d@=%k;4%+_MoxswaK{KB2behpT ziK4&k6ov)YiTkV?vA z{pQda6)bfbmpEL}vYuj@(NY;?JDoE|)uzT$84Zx~fzlehQtsuYmON@NMZiScb} zl|Bg6XPx-u(+jlI`E6bH~Oa3alq;h^K zp|7$$R4YNs*go4bq?9W2t>fY18hR$rD5zDH>C}304c_ciTS`7{QCrFlI6$vfSFU{z zW+!?Tr2ZPy3I#Q$t%ZgGd!C_%QjOkiGBaswMpc;|O7^^0ROWMg}$2r3cVj#cR725>3rRKQ+CzrKNK|=I#Uc z8|dX1`U6*0waR0)8UosI|7`eWe4PR1&XJFpdR9MhAl!LiHq<(0y>awXbH?R2dwQL+ z0_gSWE$^HetN}jA* zby@k+16p*bw7+X>k^8C39cT&nGx=Ih;%P7PK$-D828}2gDF;gHo=$(&T2nxqXV{D7 z+FZ7Mv(f}Xr3SRcH|y2be=MDICy&Tv&|h2!>R0xcV%@R{%PMfMu~x|ps?{m~C($}* zW)q2=^VT`#2ei&-am{t#@!f^=;iBIHedDv~H(ho>t7awjHEw|U`l&X~mG1hxb$(FI zmHhR!@~&DP0UY$rW3z9aW1)!WYgT>aZjmWBpcONmS%P##ux6^zW3!rBf+z^8E1=E3 zdTZ;sax+Wms)UpUZr29x&(tcRwbT;O*8B%br|-FKY^@W#sJGxf+?jHq)~W-zGC4D* z1j$?vyp4Peln;$-f7u(;|FzT-(9#*sUj6V9@wpzZPPH$WyQHN!#|I#J)zmSUyS z1KQ=ADQgpJe=R}nGWv4%bF#laQ+7a`eEgfsHaQmD8_`!z>2G$s9NX=UXqQuZK)Yr* zkN9OGNCt!EGTYMeX|LIhv!I#+TAM#IGo@KubKT}j5J7g+^Mz6(X4m#=)dujvH;d2Z zD0S20@|pPRoV!-*S_0ZR!!>Jd-R<>3$;kE9H@h}^YY1rHoN8NttBszQw)w2=>9wu& zynOlE0@^vlRhYjHYAHX~(frcV$7VM^tGCpt@6B(kGaI})ZFTAkXzNrdr)Q&w{QX)< z3BR|r>bVx@pvnVSFsDYKp9L-j>|^#^x45htp5GeJOu=UA*t+gqXLIqu*Z2kaZ&!8MZMn-XW+!Or2~fKK+Em7iU0H5|&V zvT+|Y8iO`Z^|RsjmZNVwW_GP8tM7bH&)TN7Qm3*1!6lbA_buFJ*Ot;@SGH}l;^8z7 zzOOD-qh21~4X4h#u%RhN%>AWlr^5?VQh?O^HovD+u5(a0pk$wfOsC|agR22`RNngg76>M93-c;sqawr2Gsn%b#uUXpuIshdmt%iFj9{P(~;$zz2$-dN>8 zu0Jo0ZQnt;zUflH2YJb<1ipH(4nG_XoK+b&pbQ-Mn>Hs)jwjA4KaMHRDnID=9Ru|C zq;vj=(DOg{ssmRF{CkI0<=IB6-L6Efo7E}QLfIc`0Qu>U})H{VuJF(#>bgm_FS zQ+HIRsNBrUvU0AMHB=iPj%;v=$dSckxIB=@Z|d@x2lP^v-ZT&E*M4l)JAQO8&n)*k zn{R$?R_-XQ`v9$7^SV-Am&>bPUdA5sAEd3G$F6N-?X~GcyLLXM!k_-$hR53W_a6Jl z^?!Bs6Yu@+{5XkKAF-_F27r#m42BybAu9|B#P-I;oqMc~E`5m*w?xMzni$hrxKXYh z`6u*!{%QMqp%H02^It~=q2|S%`4@3>p+2G(vdS)C3d@OUi71I&s2U=wv+#&r>c@nJ zkbS4>nyhC0T97r|phDqrxUnhJ5$WivZvt_^HaDs|V8hK#_01h!_}{p=BN}RMZbDNQ zs)ZJd>$+Hzbe812YIWql(*_bv_`0UH&ivz@1=W#%-{Ow^dn^{vnSXz0{z(ImcIH3S znSUB>?#O?HT!_6~g&JC!2)xVxDp=Lt6zVK& zktCh@qiuH9=McVhLCB^ZB)Utu+-hz`@l4Z!1{NdHWtS@{{pjkZ=Fa@LQP?M?dEqeG zrhECbo%zp7kWFHzpsi%3PK`+LUpk)wk&DlQDqwVaQuv}BmR<~pdzy$WpjGICqv5a+ z)RF%K{73K$=t>49_LPfLz%`qsklcj|LXPfznbk^Rx;wtW7*me)+bMxxlMXnpec4C_lBa1dF2L-khpvK4Mo7()n98ClJwig!q+1L!m8lMwWYYE~%g z>m7x!QV->y3e_oPnM7YV*`CtHhFZXVq{jcpn&x*F?iBIU!j2{`t?Mk*cjiAOl7b4M z77JaFl9iqLm(a;&;!$bYIFv+f`x^d-?eOcJ`PajG5ZR;BTiqpP3u}qgfgcO4g`rSm zm}9@t1?3b1(wJx_>T0=H%?NB-x zX;RYVs#)t*&PY@z?99U5w&G)5#UeuWjh%&8ThK*XvRj)tARy<3Ym4GtxYic$!nIP+ z8j4Fn!|zaN3g2ypoD{BQ0QspY!sti2U=o2;h=6^)mD7+=h)D+(au8h^X|p;CKjMIS~pk zXhIb>eT6Q_k1Zk+pwJY$E`nw%p^fx4Bjw?1kzkQb`du=~cXc(X`f#|bs|yU$O)W$^ z3lUQ)15#?lT`@*O;h~Nu_9Sb};eR+3W(6|fawZc4tTKO|m`^g$$ev!()zMV%%FO&i z2PAS~Q#~5kSy->*^RIUnhS8g-X2$}%VV#A8_z(NURCv%-co2dlL^Q)%K>^q22MwD zTpeCd!7rQ=^WlPwy{Ew>h}06(fD5_-7s93wKuZWz!=?ev%@`K!vBrp60#!<7MjHrf z^@3O{3|!VUF9g9^)meyRM50Z=F&^qP?x=uOc3z~@c_jd)V>;NJ%YdM|2h@ zi}^H@UWe4xfsV&8?MOd~38cd?{$MysR8u1?jSFCvNU|oM?3McqqRy}FQVm68M(Tt1 z!yxDtsbAF8;4eX%_ZzO}y=I#Cnj!NwZG}4bn(WuYm(qSHQq+v3N3pB*j9TV+Le_yI9Z z>~uwe(&-=&1!YsH$AO_&7%0mVax(wfT}=x>66YA)LV-&k>0sgAy1NRCZ7ROnSpW@4 z!=(@P(owBHMH$&Kri%`?UT=B0znJvX?qfjar^TW&*O<|C6iaAnZDG|4t{o^WBqV1h zKrb0NkYOszft80JhIDJzpqhosmaRfgS8FRlIOvIC(_5SBO+QH|z0~{{hZg?$ z%h$egZ}XZzy79hGZrHiL`BS$I{d~vQT5np!U5HUUBu0ObeqDW5T~6d9;ugvvG=lGt z^XXsxen>>qA4T6XUkXSMRNVgVtA3+ySE)nM?I~uIjFi!ZN_KmPFIXHPtv<18?`sE@oi{uQax1d<&r#z#m8>=;HtB? zL_ank2Mep00hENQj}b7Yz8S!Re`HBRs1g60>l!<{LX9CH!uWM9(6+kRrQ*Cn{A2ZvSi@m) zkbjz?r?^bm-ok{K6$^`sp$H@HWx5Lnhxyu0mw(NK3b|tFAalGMg%;jtaBy;=jvuj< zql~RL5rwW|=wgIy<;5hMnfR>4id(9cRcil^9i&%*iJoWjZS!@!tuwm9?e@K1VX^ur zm~K76U?(C=jC|tX29SS^p&bmp&d^A+E(pdV?)DYQI4}3fHoGLTCXrym5C=ohG%bIg z%y@jBE{MvH{OBw^WiVo|Notww7^jMvk4i{%FC&f>DR@2P1jEJPYYz6cu&F?71ap(8 zZ9s;6gyns#nDeMC6=6$)H?#}5F5o1}RG%uQx*+$zZ-}xxkb3uGCOp|;T3OVi2E#R& zp0y3e(WnNKFB%I)OmVI+($6WIb$!tgg_*e+>~eyUa05q-YPA#x4Mqq}W~%`v0@j%{ zqnkq*J{?^R3J%j|n$rX!_^zxF+^8_nyXY(J=t2^rB8^B$2P-l~T4?^$oyt5`2&w4= z4qC>iT7fXBG zAb?xM>06x$Q}!#`Qh5Soa%FFgt7XOOJP+#+)rHRH!o>uB9jX1nYp8I4?^&bW0{qI4t5tDji~7*MCs7C5n>0> z)ueH{?gEzD7HEEnwv(+UoglUWu#(%c2<@SNNtCF4jd+TI&a}%f>?npFlA;R_c~ib# zj9*_24eOM{x<$hw++rbjuuVyihwZRlrpY>;9QmenE%p^40vP;QF@j^z1BC~4_6LgX z$iMCcUt1UnQBu(sj!U_|R*c44AJHhyZe`AiIVik%cL#Xk#A8+d?qZVsg@q9;$hmxM zw%4Ob35fybaqK`CO%ZCNQyI2D6U|dt&)DIR`vwbB^yLNoZ*H~IBTUycQEV#WzHSE! zt0>1nA(Nf!3J4y3J&rft%tRcH`Hw81H$t-k3KIx$4J+!!xFFM4J1{A;io#+H%!3#b zpIw9jE0wyDPAPD^uoO?e9P_oK7j;GGo5i?8AqK%=rww}z%{V;@UkNIE9(5~eQUP+P zq>Tl=f5aO|zgozFi_Gqy^i*?eq>l7*RFnBKXX2hdW<3`)ONd@S$~Wc)N)rBb$@QQ` ze6!z{252P@ZhG!6z+Zwyre}+yQ0Q`k7hi_rZF%aluNT|b2;5yzw(UZI=^vB{-DU1{ z^KXQ9)Xl$9TE`pIeB%P-6uo7V6ORoqNel0QXt(dPDO^512S(VV2y-06!WGU3R3DIi z5gF|>Y=#;^HuUQb8ELQS``69=>nI!p?>utz0(T8GY2jg{g;i8+e*XNWk!DczBQVzV zx-CWd3vY=uLYw)}-Z6Mklx4(;9{!7_=;R93kThI&A?v`m=3bT zJQs>+=wg#N|5`Cv$T`7-lJDI`1bhW7;;5jTTbNtBcqD}3TTBU-nz9QQGiaOMlK(Y< zuLDv%O}hMfX~6|>p-U=IPSjBy6schs6Upe*PTY1dOT^@fAn80yHT6wp_eC=kO7UiQJQ<4P^I)Pg^L zK4M2+6X{RI@HH_eS>Lm!=fp!=~7pcznZ#>o=_3cztx;rqTGu8*bcq z!|3SVSp0^K>o;z=VO=ynvT2i2*I4*4VstDK+m!;jJ$=bUJeBJiNKa;B@jK$FcqW=l zXL|Oe61gd*ZnRYU?)XGHn*efZPbRs1UoJP1z3IB^#uB-GlY4t&>GA7q3a@iYRSE_! z_yh>sHg2h5C$3zLed&>SZz`Ic$|kZsPV&L2iFki%G`)KB_SED!sf%xmPsCFrpqg>n zTStb5*5R9oF-yI}$yQS>1My5EnoPVa$_{2Fed%N}9z#=IwG}JD!7H?6s4tz$<}#B^ zm5roFBRLWgIRJJfkMS!(`nyQm$yq~cn^0#`57GFZP89BUtlk4ICvL~I9c@Ww!h zN4=~lEEHtlD2q2Jm6BV3Pc*l$QFphbAksQ$C6v0#QjhOfNHrL0?@cDt2X;&*bBT#0 zUUL{~=}+wgx6lM8yL(Yh$yju?(jetOzKBbp(mFUEt7Qf$KmPfkWL9Zu^J*XkV;g+J zA86Wwi=U<^5MPZZWd4^%UuIzQ*sv}s5?D6VkIk?0VbRu;Ad1zyI-|6!EF{aX45HG< zl89YemA)p~)!IzjYUr-zmWtdHrCQ9zGdD#JQ6pZHdgQUl%0nDw45HoJEOnbRkTFId zO~m3zZHG+Cn@A1vKu=$KGL>T~IAUq3n+9^3cyv6G8oP6H?{xD+g|9v| zn0Be|m9FsZ>CAW(N^>6u^(tLq{)=GzAKNr)f>5UpxZ0@^rVWup9F5X$)12M$++-%j z1g2dMh6!(uP&LG}qWo?-&7EeIeqAN_$@ZK;ySbpB3wPoY3(a~%?*LZh4 zHI~~~RH6;ZL@K^UAdV!r!NZBM1T|Y!(;);gD5wBCY?-j<7R)ql+Y-^SR5}Z-jdyxp zr<1j7nZm%Jv|L=gb4@qBnK7h?mTF^d_TQ(nXa7T4JMLjsPvZCa^&$27i+HF1KnUD4 zIMaz=|Avt2zu1XmiUkC&zug1d2Co0%eQP%Ee$VYke&>!p>wOOOp(5?gB zh`Um94I-A0L}am*!Yv*9IJp$@srq+A4OsR@T0#z1`%8M8q`6+1e>Y%H4Lrb)bee57 z)-i<^>93)&_&(h8U5=!00`~{;;X$iNDc>8N#TF6|bWeEb3fkr=-3qF_W#zmR7z+ZM zPSdXYP_OG)J>u76D{BpYH{!>39mE$9EcA|foRpthPP$q)xAgU3r;=|_f)xR&gP{ug z_?^3?aCQPbB!|Yp#~ji;k3sI`>ovfTR(>;#f=SwU*?HKbEXlN;cYNSRVQ)0(Yme^D zv>r%BrENhskDWG5NFVckk9-58-kNpG#N5`a)M0fU+Uu>aw1=JkU9C2#P2kiT@F0#b z^fZ2J)ka*SY8~SEhTn~N;O0hweBlr$5puE-sc%5KC@>>PjkPKMZj^D*3u(>* s&mCueJ1l~c>6J8x4lQSr`Dfs#g9F!x6c=1CZTRUR=Vw&Bxg7Za0OJg!%m4rY literal 0 HcmV?d00001 diff --git a/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll.meta b/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll.meta new file mode 100644 index 000000000..ac3891d15 --- /dev/null +++ b/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll.meta @@ -0,0 +1,88 @@ +fileFormatVersion: 2 +guid: e7347bf77bb9de34ea1bf2ac2d600fdc +labels: +- RoslynAnalyzer +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CPU: AnyCPU + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/samples/ChatApp/ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs b/samples/ChatApp/ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs deleted file mode 100644 index fbafd63ae..000000000 --- a/samples/ChatApp/ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs +++ /dev/null @@ -1,355 +0,0 @@ -// -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. - -namespace MagicOnion -{ - using global::System; - using global::System.Collections.Generic; - using global::System.Linq; - using global::MagicOnion; - using global::MagicOnion.Client; - - public static partial class MagicOnionInitializer - { - static bool isRegistered = false; - -#if UNITY_2019_4_OR_NEWER - [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] -#elif NET5_0_OR_GREATER - [System.Runtime.CompilerServices.ModuleInitializer] -#endif - public static void Register() - { - if (isRegistered) return; - isRegistered = true; - - global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default = - (global::MagicOnion.Client.MagicOnionClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider immutableMagicOnionClientFactoryProvider) - ? immutableMagicOnionClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableMagicOnionClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - - global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default = - (global::MagicOnion.Client.StreamingHubClientFactoryProvider.Default is global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider immutableStreamingHubClientFactoryProvider) - ? immutableStreamingHubClientFactoryProvider.Add(MagicOnionGeneratedClientFactoryProvider.Instance) - : new global::MagicOnion.Client.ImmutableStreamingHubClientFactoryProvider(MagicOnionGeneratedClientFactoryProvider.Instance); - } - } - - public partial class MagicOnionGeneratedClientFactoryProvider : global::MagicOnion.Client.IMagicOnionClientFactoryProvider, global::MagicOnion.Client.IStreamingHubClientFactoryProvider - { - public static MagicOnionGeneratedClientFactoryProvider Instance { get; } = new MagicOnionGeneratedClientFactoryProvider(); - - MagicOnionGeneratedClientFactoryProvider() {} - - bool global::MagicOnion.Client.IMagicOnionClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.MagicOnionClientFactoryDelegate factory) - => (factory = MagicOnionClientFactoryCache.Factory) != null; - - bool global::MagicOnion.Client.IStreamingHubClientFactoryProvider.TryGetFactory(out global::MagicOnion.Client.StreamingHubClientFactoryDelegate factory) - => (factory = StreamingHubClientFactoryCache.Factory) != null; - - static class MagicOnionClientFactoryCache where T : global::MagicOnion.IService - { - public readonly static global::MagicOnion.Client.MagicOnionClientFactoryDelegate Factory; - - static MagicOnionClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.MagicOnionClientFactoryDelegate); - - if (typeof(T) == typeof(global::ChatApp.Shared.Services.IChatService)) - { - factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate)((x, y) => new ChatApp.Shared.Services.ChatServiceClient(x, y))); - } - Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; - } - } - - static class StreamingHubClientFactoryCache where TStreamingHub : global::MagicOnion.IStreamingHub - { - public readonly static global::MagicOnion.Client.StreamingHubClientFactoryDelegate Factory; - - static StreamingHubClientFactoryCache() - { - object factory = default(global::MagicOnion.Client.StreamingHubClientFactoryDelegate); - - if (typeof(TStreamingHub) == typeof(global::ChatApp.Shared.Hubs.IChatHub) && typeof(TReceiver) == typeof(global::ChatApp.Shared.Hubs.IChatHubReceiver)) - { - factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate)((a, _, b, c, d, e) => new ChatApp.Shared.Hubs.ChatHubClient(a, b, c, d, e))); - } - - Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; - } - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. -namespace MagicOnion.Resolvers -{ - using global::System; - using global::MessagePack; - public class MagicOnionResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new MagicOnionResolver(); - - MagicOnionResolver() {} - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - => FormatterCache.formatter; - - static class FormatterCache - { - public static readonly global::MessagePack.Formatters.IMessagePackFormatter formatter; - - static FormatterCache() - { - var f = MagicOnionResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - internal static class MagicOnionResolverGetFormatterHelper - { - static readonly global::System.Collections.Generic.Dictionary lookup; - - static MagicOnionResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(3) - { - {typeof(global::MagicOnion.DynamicArgumentTuple, global::System.Collections.Generic.Dictionary>), 0 }, - {typeof(global::System.Collections.Generic.Dictionary), 1 }, - {typeof(global::System.Collections.Generic.List), 2 }, - }; - } - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MagicOnion.DynamicArgumentTupleFormatter, global::System.Collections.Generic.Dictionary>(default(global::System.Collections.Generic.List), default(global::System.Collections.Generic.Dictionary)); - case 1: return new global::MessagePack.Formatters.DictionaryFormatter(); - case 2: return new global::MessagePack.Formatters.ListFormatter(); - default: return null; - } - } - } -} -#pragma warning restore 168 -#pragma warning restore 219 -#pragma warning restore 414 -#pragma warning restore 612 -#pragma warning restore 618 - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. - -namespace ChatApp.Shared.Services -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class ChatServiceClient : global::MagicOnion.Client.MagicOnionClientBase, global::ChatApp.Shared.Services.IChatService - { - class ClientCore - { - public global::MagicOnion.Client.Internal.RawMethodInvoker GenerateException; - public global::MagicOnion.Client.Internal.RawMethodInvoker SendReportAsync; - public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) - { - this.GenerateException = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IChatService", "GenerateException", serializerProvider); - this.SendReportAsync = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_RefType_ValueType(global::Grpc.Core.MethodType.Unary, "IChatService", "SendReportAsync", serializerProvider); - } - } - - readonly ClientCore core; - - public ChatServiceClient(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) - { - this.core = new ClientCore(serializerProvider); - } - - private ChatServiceClient(MagicOnionClientOptions options, ClientCore core) : base(options) - { - this.core = core; - } - - protected override global::MagicOnion.Client.MagicOnionClientBase Clone(global::MagicOnion.Client.MagicOnionClientOptions options) - => new ChatServiceClient(options, core); - - public global::MagicOnion.UnaryResult GenerateException(global::System.String message) - => this.core.GenerateException.InvokeUnaryNonGeneric(this, "IChatService/GenerateException", message); - public global::MagicOnion.UnaryResult SendReportAsync(global::System.String message) - => this.core.SendReportAsync.InvokeUnaryNonGeneric(this, "IChatService/SendReportAsync", message); - } -} - - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 219 -#pragma warning disable 168 - -// NOTE: Disable warnings for nullable reference types. -// `#nullable disable` causes compile error on old C# compilers (-7.3) -#pragma warning disable 8603 // Possible null reference return. -#pragma warning disable 8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable. -#pragma warning disable 8625 // Cannot convert null literal to non-nullable reference type. - -namespace ChatApp.Shared.Hubs -{ - using global::System; - using global::Grpc.Core; - using global::MagicOnion; - using global::MagicOnion.Client; - using global::MessagePack; - - [global::MagicOnion.Ignore] - public class ChatHubClient : global::MagicOnion.Client.StreamingHubClientBase, global::ChatApp.Shared.Hubs.IChatHub - { - protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } - - public ChatHubClient(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) - : base(callInvoker, host, options, serializerProvider, logger) - { - var marshaller = global::MagicOnion.MagicOnionMarshallers.ThroughMarshaller; - DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "IChatHub", "Connect", marshaller, marshaller); - } - - public global::System.Threading.Tasks.Task JoinAsync(global::ChatApp.Shared.MessagePackObjects.JoinRequest request) - => base.WriteMessageWithResponseAsync(-733403293, request); - public global::System.Threading.Tasks.Task LeaveAsync() - => base.WriteMessageWithResponseAsync(1368362116, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task SendMessageAsync(global::System.String message) - => base.WriteMessageWithResponseAsync(-601690414, message); - public global::System.Threading.Tasks.Task GenerateException(global::System.String message) - => base.WriteMessageWithResponseAsync(517938971, message); - public global::System.Threading.Tasks.Task SampleMethod(global::System.Collections.Generic.List sampleList, global::System.Collections.Generic.Dictionary sampleDictionary) - => base.WriteMessageWithResponseAsync, global::System.Collections.Generic.Dictionary>, global::MessagePack.Nil>(-852153394, new global::MagicOnion.DynamicArgumentTuple, global::System.Collections.Generic.Dictionary>(sampleList, sampleDictionary)); - - public global::ChatApp.Shared.Hubs.IChatHub FireAndForget() - => new FireAndForgetClient(this); - - [global::MagicOnion.Ignore] - class FireAndForgetClient : global::ChatApp.Shared.Hubs.IChatHub - { - readonly ChatHubClient parent; - - public FireAndForgetClient(ChatHubClient parent) - => this.parent = parent; - - public global::ChatApp.Shared.Hubs.IChatHub FireAndForget() => this; - public global::System.Threading.Tasks.Task DisposeAsync() => throw new global::System.NotSupportedException(); - public global::System.Threading.Tasks.Task WaitForDisconnect() => throw new global::System.NotSupportedException(); - - public global::System.Threading.Tasks.Task JoinAsync(global::ChatApp.Shared.MessagePackObjects.JoinRequest request) - => parent.WriteMessageFireAndForgetAsync(-733403293, request); - public global::System.Threading.Tasks.Task LeaveAsync() - => parent.WriteMessageFireAndForgetAsync(1368362116, global::MessagePack.Nil.Default); - public global::System.Threading.Tasks.Task SendMessageAsync(global::System.String message) - => parent.WriteMessageFireAndForgetAsync(-601690414, message); - public global::System.Threading.Tasks.Task GenerateException(global::System.String message) - => parent.WriteMessageFireAndForgetAsync(517938971, message); - public global::System.Threading.Tasks.Task SampleMethod(global::System.Collections.Generic.List sampleList, global::System.Collections.Generic.Dictionary sampleDictionary) - => parent.WriteMessageFireAndForgetAsync, global::System.Collections.Generic.Dictionary>, global::MessagePack.Nil>(-852153394, new global::MagicOnion.DynamicArgumentTuple, global::System.Collections.Generic.Dictionary>(sampleList, sampleDictionary)); - - } - - protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) - { - switch (methodId) - { - case -1297457280: // Void OnJoin(global::System.String name) - { - var value = base.Deserialize(data); - receiver.OnJoin(value); - } - break; - case 532410095: // Void OnLeave(global::System.String name) - { - var value = base.Deserialize(data); - receiver.OnLeave(value); - } - break; - case -552695459: // Void OnSendMessage(global::ChatApp.Shared.MessagePackObjects.MessageResponse message) - { - var value = base.Deserialize(data); - receiver.OnSendMessage(value); - } - break; - } - } - - protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) - { - switch (methodId) - { - case -733403293: // Task JoinAsync(global::ChatApp.Shared.MessagePackObjects.JoinRequest request) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 1368362116: // Task LeaveAsync() - base.SetResultForResponse(taskCompletionSource, data); - break; - case -601690414: // Task SendMessageAsync(global::System.String message) - base.SetResultForResponse(taskCompletionSource, data); - break; - case 517938971: // Task GenerateException(global::System.String message) - base.SetResultForResponse(taskCompletionSource, data); - break; - case -852153394: // Task SampleMethod(global::System.Collections.Generic.List sampleList, global::System.Collections.Generic.Dictionary sampleDictionary) - base.SetResultForResponse(taskCompletionSource, data); - break; - } - } - - } -} - - diff --git a/samples/ChatApp/ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs.meta b/samples/ChatApp/ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs.meta deleted file mode 100644 index c592247bd..000000000 --- a/samples/ChatApp/ChatApp.Unity/Assets/Scripts/Generated/MagicOnion.Generated.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8ab05ebd7a5a3d949ab3b65364c38729 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/samples/ChatApp/ChatApp.Unity/Assets/Scripts/InitialSettings.cs b/samples/ChatApp/ChatApp.Unity/Assets/Scripts/InitialSettings.cs index 774c0e450..922b15e3c 100644 --- a/samples/ChatApp/ChatApp.Unity/Assets/Scripts/InitialSettings.cs +++ b/samples/ChatApp/ChatApp.Unity/Assets/Scripts/InitialSettings.cs @@ -1,5 +1,6 @@ using System.IO; using Grpc.Core; +using MagicOnion.Client; #if USE_GRPC_NET_CLIENT using Grpc.Net.Client; #endif @@ -10,6 +11,9 @@ namespace Assets.Scripts { + [MagicOnionClientGeneration(typeof(ChatApp.Shared.Services.IChatService))] + partial class MagicOnionClientInitializer {} + class InitialSettings { [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -17,7 +21,7 @@ static void RegisterResolvers() { // NOTE: Currently, CompositeResolver doesn't work on Unity IL2CPP build. Use StaticCompositeResolver instead of it. StaticCompositeResolver.Instance.Register( - MagicOnion.Resolvers.MagicOnionResolver.Instance, + MagicOnionClientInitializer.Resolver, MessagePack.Resolvers.GeneratedResolver.Instance, BuiltinResolver.Instance, PrimitiveObjectResolver.Instance From 8a013d03e59b9db7f9078def3c7937e561869b4c Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Fri, 20 Oct 2023 11:03:40 +0900 Subject: [PATCH 50/66] Move MagicOnion.Client.SourceGenerator.Unity.dll to package --- .../MagicOnion.Client.SourceGenerator.Unity.meta | 2 +- .../MagicOnion.Client.SourceGenerator.Unity.dll | Bin ...MagicOnion.Client.SourceGenerator.Unity.dll.meta | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename {samples/ChatApp/ChatApp.Unity/Assets/Plugins => src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client}/MagicOnion.Client.SourceGenerator.Unity.meta (77%) rename {samples/ChatApp/ChatApp.Unity/Assets/Plugins => src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client}/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll (100%) rename {samples/ChatApp/ChatApp.Unity/Assets/Plugins => src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client}/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll.meta (100%) diff --git a/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity.meta b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity.meta similarity index 77% rename from samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity.meta rename to src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity.meta index d08c2e13b..a8a7256ef 100644 --- a/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity.meta +++ b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 593eb477f7a9c214d84196026c0e8b13 +guid: 11222ebf80058bb47b90803c0b591411 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll similarity index 100% rename from samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll rename to src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll diff --git a/samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll.meta b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll.meta similarity index 100% rename from samples/ChatApp/ChatApp.Unity/Assets/Plugins/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll.meta rename to src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll.meta From 129c7d5db449aa7690df6bc5d47162b1b04697d5 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Fri, 20 Oct 2023 11:19:35 +0900 Subject: [PATCH 51/66] Add comments --- Directory.Build.props | 6 ------ src/Directory.Build.props | 7 +++++++ .../CodeGen/MagicOnionInitializerGenerator.cs | 10 ++++++++++ .../MemoryPackFormatterRegistrationGenerator.cs | 3 +++ .../CodeGen/MessagePackFormatterResolverGenerator.cs | 3 +++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../Return/0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../Return/0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ..._MyApplication1_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_MyApplication1_MagicOnionInitializer.g.cs | 10 ++++++++++ ...n1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs | 3 +++ ...pplication1_Net_Remoting_MagicOnionInitializer.g.cs | 10 ++++++++++ ...002_MyNamespace_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_MyNamespace_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ...001_TempProject_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002_TempProject_MagicOnionInitializer.g.cs | 10 ++++++++++ ..._MyApplication1_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_MyApplication1_MagicOnionInitializer.g.cs | 10 ++++++++++ ..._MyApplication1_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_MyApplication1_MagicOnionInitializer.g.cs | 10 ++++++++++ .../0001__MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0002__MagicOnionInitializer.g.cs | 10 ++++++++++ ..._MyApplication1_MagicOnionInitializer_Resolver.g.cs | 3 +++ .../0003_MyApplication1_MagicOnionInitializer.g.cs | 10 ++++++++++ 175 files changed, 1128 insertions(+), 6 deletions(-) create mode 100644 src/Directory.Build.props diff --git a/Directory.Build.props b/Directory.Build.props index 025032138..a1759a12e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -31,10 +31,4 @@ - - - - $(MSBuildThisFileDirectory) - $(RepoRoot)=. - diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 000000000..27504679f --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,7 @@ + + + + $(MSBuildThisFileDirectory) + $(RepoRoot)=. + + diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs index f7e93a977..6bb6b8412 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs @@ -36,7 +36,14 @@ partial class {{generationContext.InitializerPartialTypeName}} static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; """); @@ -53,6 +60,9 @@ partial class {{generationContext.InitializerPartialTypeName}} } writer.WriteLine($$""" + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs index 751023372..1aa00374a 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs @@ -53,6 +53,9 @@ static void EmitRegister(GenerationContext generationContext, SerializationForma ctx.TextWriter.WriteLine($$""" partial class {{generationContext.InitializerPartialTypeName}} { + /// + /// Registers the generated MemoryPackFormatters. + /// public static void RegisterMemoryPackFormatters() { """); diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs index 379d82ce1..351557438 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs @@ -40,6 +40,9 @@ namespace {{generationContext.Namespace}} partial class {{generationContext.InitializerPartialTypeName}} { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; """); diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index a66075dd6..ca89524bc 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Nested/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 76d5c9a7f..a8860cf0a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 624c513a6..974fe70dd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Parameter_Nullable/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 76d5c9a7f..a8860cf0a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 624c513a6..974fe70dd 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateEnumFormatterTest/GenerateEnumFormatter_Return_Nullable/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 364edd7ea..9a6e2b741 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 33c1c862a..7f2cc5829 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d5382352d..d21d381c4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 6c7b8ec6c..190e24943 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 31efb2b9c..c2bfbed94 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c0fe9bc08..f8ded1533 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d0d33bed1..efabfa5ad 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index f2c5d63ba..1d5f9df91 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index a50da026a..14682098c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 49fb95d42..120f8419c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/HubReceiver_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 364edd7ea..9a6e2b741 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 33c1c862a..7f2cc5829 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d5382352d..d21d381c4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 31efb2b9c..c2bfbed94 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c0fe9bc08..f8ded1533 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d0d33bed1..efabfa5ad 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index f2c5d63ba..1d5f9df91 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index a50da026a..14682098c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 49fb95d42..120f8419c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 364edd7ea..9a6e2b741 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 33c1c862a..7f2cc5829 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d5382352d..d21d381c4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 6c7b8ec6c..190e24943 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 31efb2b9c..c2bfbed94 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c0fe9bc08..f8ded1533 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d0d33bed1..efabfa5ad 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index f2c5d63ba..1d5f9df91 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index a50da026a..14682098c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 49fb95d42..120f8419c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsStreamingHubTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index cad15a649..aa119ff72 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/KnownFormatters/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 926c25af7..9fd44d4ae 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 33c1c862a..7f2cc5829 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d5382352d..d21d381c4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 31efb2b9c..c2bfbed94 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c0fe9bc08..f8ded1533 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index f2c5d63ba..1d5f9df91 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index a50da026a..14682098c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 49fb95d42..120f8419c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Parameters_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 364edd7ea..9a6e2b741 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 33c1c862a..7f2cc5829 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d5382352d..d21d381c4 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ArrayFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 6c7b8ec6c..190e24943 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 31efb2b9c..c2bfbed94 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_KnownType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index c0fe9bc08..f8ded1533 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_ListFormatter_UserType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index d0d33bed1..efabfa5ad 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_MultipleTypeArgs/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index f2c5d63ba..1d5f9df91 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index a50da026a..14682098c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Array/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs index 49fb95d42..120f8419c 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0002_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateGenericsTest/Return_Nested_Enum/0003_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 0c7cd04fd..5bbd9ab2b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateRawStreamingTest/StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ee7015b3..62457f11b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs index d641e68ef..af99df707 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonGenerics/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ee7015b3..62457f11b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index d641e68ef..af99df707 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_NonSupportedUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ee7015b3..62457f11b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs index d641e68ef..af99df707 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_RawStreaming_NonTask/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ee7015b3..62457f11b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index d641e68ef..af99df707 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Invalid_Return_TaskOfUnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 0c7cd04fd..5bbd9ab2b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_StreamingResult/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index a1d1dce87..653917804 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultNonGeneric/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 0c7cd04fd..5bbd9ab2b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfRefType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 1411ccbd2..2041451a3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 191cdef8d..0d6c859b1 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateServiceTest/Return_UnaryResultOfValueType/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 926f5afdb..24f673f85 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Complex/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 6c5837478..1821232f8 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index f4cf2d86f..e251d9b80 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index f4cf2d86f..e251d9b80 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/HubReceiver_Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ee7015b3..62457f11b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs index d641e68ef..af99df707 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_HubReceiver_ReturnsNotVoid/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 5ee7015b3..62457f11b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs index d641e68ef..af99df707 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Invalid_Return_Void/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 87e974005..e8362759a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Many/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 0c7cd04fd..5bbd9ab2b 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_One/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index a1d1dce87..653917804 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Parameter_Zero/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index f4cf2d86f..e251d9b80 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_Task/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 10afef018..ea0f14631 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_TaskOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index f4cf2d86f..e251d9b80 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTask/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 10afef018..ea0f14631 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateStreamingHubTest/Return_ValueTaskOfT/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index fd32b89ba..3ba8ea1ac 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace MyApplication1 partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs index dbde9de8e..843084e18 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs index c644059c3..7f4496157 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0002_MyApplication1_Net_Remoting_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace MyApplication1.Net.Remoting partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs index 494723c73..9ec3d0e1a 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/Generate_Namespace/0003_MyApplication1_Net_Remoting_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Resolver.g.cs index 4ecea31cf..511db91c5 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0002_MyNamespace_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace MyNamespace partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer.g.cs index 5962afe29..ef83ac193 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateTest/ImplicitUsings_PropertyGroup_Enable/0003_MyNamespace_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 1411ccbd2..2041451a3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs index 849877a9a..a5d5a9d3e 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_Service_Interface/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs index 1411ccbd2..2041451a3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0001_TempProject_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace TempProject partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs index bae44ef82..161a3a7c6 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GenerateWithIfDirectiveTest/Skip_Generation_StreamingHub_Interface/0002_TempProject_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index 95b1e658d..43bfda7f3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace MyApplication1 partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0003_MyApplication1_MagicOnionInitializer.g.cs index dbde9de8e..843084e18 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0003_MyApplication1_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Default/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index 95b1e658d..43bfda7f3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace MyApplication1 partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0003_MyApplication1_MagicOnionInitializer.g.cs index afb573424..6f1483882 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0003_MyApplication1_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/DisableAutoRegistration/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -17,9 +17,19 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs index 8fee89505..88d8b49aa 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0001__MagicOnionInitializer_Resolver.g.cs @@ -9,6 +9,9 @@ partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0002__MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0002__MagicOnionInitializer.g.cs index faac112f0..24a33b0cb 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0002__MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/MessagePackFormatterNamespace/0002__MagicOnionInitializer.g.cs @@ -15,7 +15,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -24,6 +31,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs index 95b1e658d..43bfda7f3 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0002_MyApplication1_MagicOnionInitializer_Resolver.g.cs @@ -11,6 +11,9 @@ namespace MyApplication1 partial class MagicOnionInitializer { + /// + /// Gets the generated MessagePack formatter resolver. + /// public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { diff --git a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0003_MyApplication1_MagicOnionInitializer.g.cs b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0003_MyApplication1_MagicOnionInitializer.g.cs index dbde9de8e..843084e18 100644 --- a/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0003_MyApplication1_MagicOnionInitializer.g.cs +++ b/tests/MagicOnion.Client.SourceGenerator.Tests/Resources/GeneratorOptionsTest/Serializer_MemoryPack/0003_MyApplication1_MagicOnionInitializer.g.cs @@ -17,7 +17,14 @@ partial class MagicOnionInitializer static bool isRegistered = false; readonly static MagicOnionGeneratedClientFactoryProvider provider = new(); + /// + /// Gets the generated MagicOnionClientFactoryProvider. + /// public static global::MagicOnion.Client.IMagicOnionClientFactoryProvider ClientFactoryProvider => provider; + + /// + /// Gets the generated StreamingHubClientFactoryProvider. + /// public static global::MagicOnion.Client.IStreamingHubClientFactoryProvider StreamingHubClientFactoryProvider => provider; #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] @@ -26,6 +33,9 @@ partial class MagicOnionInitializer #endif internal static void Register() => TryRegisterProviderFactory(); + /// + /// Register the generated client factory providers if it's not registered yet. This method will register only once. + /// public static bool TryRegisterProviderFactory() { if (isRegistered) return false; From 5905d74313fd10e597008eadd4f3218172434940 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Fri, 20 Oct 2023 11:25:20 +0900 Subject: [PATCH 52/66] Fix build --- .../MagicOnion.Integration.Tests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/MagicOnion.Integration.Tests/MagicOnion.Integration.Tests.csproj b/tests/MagicOnion.Integration.Tests/MagicOnion.Integration.Tests.csproj index 30ab51c79..7891901e0 100644 --- a/tests/MagicOnion.Integration.Tests/MagicOnion.Integration.Tests.csproj +++ b/tests/MagicOnion.Integration.Tests/MagicOnion.Integration.Tests.csproj @@ -46,5 +46,4 @@ - From 8433e94ef714117f11763d7d0f887b4341732757 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Fri, 20 Oct 2023 11:30:26 +0900 Subject: [PATCH 53/66] Use Unity 2021.3.0f1 --- .github/workflows/build-debug.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-debug.yml b/.github/workflows/build-debug.yml index 97219ace3..6eda35b24 100644 --- a/.github/workflows/build-debug.yml +++ b/.github/workflows/build-debug.yml @@ -47,7 +47,7 @@ jobs: if: "((github.event_name == 'push' && github.repository_owner == 'Cysharp') || startsWith(github.event.pull_request.head.label, 'Cysharp:'))" strategy: matrix: - unity: ["2020.3.33f1"] + unity: ["2021.3.0f1"] runs-on: ubuntu-latest timeout-minutes: 15 steps: From e13fecb15692393e679bff17bf3adf382fbd14cf Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Fri, 20 Oct 2023 16:52:08 +0900 Subject: [PATCH 54/66] Source generator is now bundled with MagicOnion.Client --- .../MagicOnion.Client.SourceGenerator.csproj | 13 ++++++++++--- .../MagicOnion.Client.SourceGenerator.targets | 10 ---------- src/MagicOnion.Client/MagicOnion.Client.csproj | 5 +++++ 3 files changed, 15 insertions(+), 13 deletions(-) delete mode 100644 src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj index 1e60b7f71..ede71929a 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.csproj @@ -1,8 +1,11 @@ - + netstandard2.0 + true + ..\MagicOnion\opensource.snk + latest enable enable @@ -12,8 +15,14 @@ true cs + + false + + + + @@ -30,6 +39,4 @@ - - diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets b/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets deleted file mode 100644 index d9a67a6ac..000000000 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnion.Client.SourceGenerator.targets +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/MagicOnion.Client/MagicOnion.Client.csproj b/src/MagicOnion.Client/MagicOnion.Client.csproj index 0bab4bb55..a28babb46 100644 --- a/src/MagicOnion.Client/MagicOnion.Client.csproj +++ b/src/MagicOnion.Client/MagicOnion.Client.csproj @@ -25,6 +25,11 @@ + + + + + From 5bbbcb5c9e5015b48337f6d3811a8924010a3eaa Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Fri, 20 Oct 2023 18:38:08 +0900 Subject: [PATCH 55/66] Update README.md --- README.md | 125 ++++++++++++++++++++++++++---------------------------- 1 file changed, 59 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index a77efcef9..9f93b57d4 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ MagicOnion client supports a wide range of platforms, including .NET Framework 4 - Client-side (MagicOnion.Client) - .NET Standard 2.1 (.NET Core 3.x+, .NET 5.0+, Xamarin) - .NET Standard 2.0 (.NET Framework 4.6.1+, Universal Windows Platform, .NET Core 2.x) - - Unity 2020.3 (LTS) or newer + - Unity 2021.3 (LTS) or newer ## Quick Start ### Server-side project @@ -192,6 +192,7 @@ dotnet add package MagicOnion - [Dependency Injection](#dependency-injection) - [Project Structure](#project-structure) - Client + - [Ahead-of-Time compilation support with Source Generator](#ahead-of-time-compilation-support-with-source-generator) - [Support for Unity client](#support-for-unity-client) - [iOS build with gRPC](#ios-build-with-grpc) - [Stripping debug symbols from ios/libgrpc.a](#stripping-debug-symbols-from-ioslibgrpca) @@ -956,58 +957,47 @@ see: [samples](https://github.com/Cysharp/MagicOnion/tree/master/samples) page a # Clients -## Support for Unity client -MagicOnion supports from Unity version 2018.4.13f1 and above, which is available for `.NET 4.x` runtime and C# 7.3 or latest. - -Using MagicOnion with Unity client requires the following four things: +## Ahead-of-Time compilation support with Source Generator -- MagicOnion.Client.Unity.package (Unity asset package for MagicOnion library) -- gRPC library for Unity client (gRPC official) -- MessagePack for C# -- MagicOnion code generator (for IL2CPP) - -### MagicOnion.Client.Unity.package (Unity asset package for MagicOnion library) -`MagicOnion.Client.Unity.package` is available for download from [Releases](https://github.com/cysharp/MagicOnion/releases) page of this repository. +MagicOnion supports Unity, NativeAOT, and other platforms that require pre-generated client code with Source Generator (MagicOnion.Client.SourceGenerator). -The package contains the code to use MagicOnion with Unity. It consists of several extensions for Unity in addition to MagicOnion.Client NuGet package. +MagicOnion.Client.SourceGenerator is shipped with MagicOnion.Client package. +This means that you no longer need to the install generator tool (moc) and setup additional build steps. -### gRPC library for Unity client (gRPC official) -gRPC library is not included in MagicOnion package. You need to download and install separately. +### Supported development environments +- Unity 2021.3.0f1 or later +- .NET 6 or later +- Visual Studio 2022 version 17.2 or later +- Rider 2023.1 or later -gRPC library can be found at [gRPC daily builds](https://packages.grpc.io/), click `Build ID`, then click `grpc_unity_package.*.*.*-dev.zip` to download the library. See [gRPC C# - experimental support for Unity](https://github.com/grpc/grpc/tree/master/src/csharp/experimental#unity) for details. +### Usage +Define a `partial` class with any name of your choosing within the application. Mark it with the `MagicOnionClientGeneration` attribute, and specify any service type found within the assembly where you want to search for the service interface. -> **NOTE**: If you encounter error about `Google.Protobuf.dll`, you can remove the library. MagicOnion does not depend `Google.Protobuf.dll`. ([Issue#296](https://github.com/Cysharp/MagicOnion/issues/296)) +For example, if the `MyApp.Shared` assembly contains `MyApp.Shared.Services.IGreeterService` and `MyApp.Shared.Hubs.IChatHub`, specify one of them. -> **NOTE**: gRPC native library for iOS has a file size of over 100MB, which may cause problems when pushing to GitHub or others. For more information on solutions, see [Stripping debug symbols from ios/libgrpc.a](#stripping-debug-symbols-from-ioslibgrpca). - -### MessagePack for C# -MessagePack for C# is not included in MagicOnion package. You need to download and install separately. - -See [MessagePack for C# installation for Unity](https://github.com/neuecc/MessagePack-CSharp#unity) for details. - -### MagicOnion code generator (for IL2CPP) - -MagicOnion's default client only supports Unity Editor or non-IL2CPP environments (e.g. Windows/macOS/Linux Standalone). If you want to use MagicOnion on IL2CPP environments, you need to generate a client and register it in your Unity project. - -#### MessagePack for C# -For the same reason, MessagePack for C# code generation is also required. +```csharp +using MagicOnion.Client; -See [MessagePack-CSharp AOT Code Generation (to support Unity/Xamarin) -](https://github.com/neuecc/MessagePack-CSharp#aot-code-generation-to-support-unityxamarin) section for more details about MessagePack code generation. +[MagicOnionClientGeneration(typeof(MyApp.Shared.Services.IGreeterService))] +partial class MagicOnionGeneratedClientInitializer {} +``` -MagicOnion code generator also generates code for MessagePack and requires Resolver registration. +Next, configure MessagePack to use the generated MessagePack Resolver. This is the same as when using the legacy MagicOnion.Generator. ```csharp -[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] +#if UNITY_2019_4_OR_NEWER +[UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] +#elif NET5_0_OR_GREATER +[System.Runtime.CompilerServices.ModuleInitializer] +#endif static void RegisterResolvers() { - // NOTE: Currently, CompositeResolver doesn't work on Unity IL2CPP build. Use StaticCompositeResolver instead of it. StaticCompositeResolver.Instance.Register( - // This resolver is generated by MagicOnion's code generator. - MagicOnion.Resolvers.MagicOnionResolver.Instance, - // This resolver is generated by MessagePack's code generator. + // Add: Use MessagePack formatter resolver generated by the source generator. + MagicOnionGeneratedClientInitializer.Resolver, MessagePack.Resolvers.GeneratedResolver.Instance, - StandardResolver.Instance + BuiltinResolver.Instance, + PrimitiveObjectResolver.Instance ); MessagePackSerializer.DefaultOptions = MessagePackSerializer.DefaultOptions @@ -1015,42 +1005,45 @@ static void RegisterResolvers() } ``` -#### `moc` (MagicOnion Codegen) command line tool -`moc` is a cross-platform application. It requires [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download) to run it. +### Source generation options +You can specify options in the named constructor of the attribute. -You can download a binary from [Releases](https://github.com/cysharp/MagicOnion/releases) page in this repository or install the tool as .NET Core tools. We recommend installing it as a local tool for .NET Core tools because of its advantages, such as fixing version per project. +- **`DisableAutoRegistration`**: Sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) +- **`MessagePackFormatterNamespace`**: Sets the namespace of pre-generated MessagePackFormatters. The default value is `MessagePack.Formatters`. +- **`Serializer`**: Sets the serializer used for message serialization. The default value is `GenerateSerializerType.MessagePack`. -To install as a [.NET Core tools (local tool)](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools#install-a-local-tool), you can run the following command: -```bash -dotnet new tool-manifest -dotnet tool install MagicOnion.Generator -``` +## Support for Unity client +MagicOnion supports from Unity version 2021.3.0f1 (LTS) and above, which is available for `.NET 4.x` runtime and C# 9 or latest. -If `moc` is installed as a local tool, you can run it with `dotnet moc` command. +Using MagicOnion with Unity client requires the following things: -```bash -$ dotnet moc --help +- MagicOnion.Client.Unity.package (Unity asset package for MagicOnion library) +- gRPC library for Unity client (gRPC official) +- MessagePack for C# -Usage: [options...] +### MagicOnion.Client.Unity.package (Unity asset package for MagicOnion library) +`MagicOnion.Client.Unity.package` is available for download from [Releases](https://github.com/cysharp/MagicOnion/releases) page of this repository. -MagicOnion Code Generator generates client codes for Ahead-of-Time compilation. +The package contains the code to use MagicOnion with Unity. It consists of several extensions for Unity in addition to MagicOnion.Client NuGet package. -Options: - -i, --input The path to the project (.csproj) to generate the client. (Required) - -o, --output The generated file path (single file) or the directory path to generate the files (multiple files). (Required) - -u, --no-use-unity-attr Do not use UnityEngine's RuntimeInitializeOnLoadMethodAttribute on MagicOnionInitializer. (Same as --disable-auto-register) (Optional) - -d, --disable-auto-register Do not automatically call MagicOnionInitializer during start-up. (Automatic registration requires .NET 5+ or Unity) (Optional) - -n, --namespace The namespace of clients to generate. (Default: MagicOnion) - -m, --messagepack-formatter-namespace The namespace of pre-generated MessagePackFormatters. (Default: MessagePack.Formatters) - -c, --conditional-symbol The conditional compiler symbols used during code analysis. The value is split by ','. (Default: null) - -v, --verbose Enable verbose logging (Optional) - -s, --serializer The serializer used for message serialization (Default: MessagePack) -``` +### gRPC library for Unity client (gRPC official) +gRPC library is not included in MagicOnion package. You need to download and install separately. -```bash -dotnet moc -i ./Assembly-CSharp.csproj -o Assets/Scripts/MagicOnion.Generated.cs -``` +gRPC library can be found at [gRPC daily builds](https://packages.grpc.io/), click `Build ID`, then click `grpc_unity_package.*.*.*-dev.zip` to download the library. See [gRPC C# - experimental support for Unity](https://github.com/grpc/grpc/tree/master/src/csharp/experimental#unity) for details. + +> **NOTE**: If you encounter error about `Google.Protobuf.dll`, you can remove the library. MagicOnion does not depend `Google.Protobuf.dll`. ([Issue#296](https://github.com/Cysharp/MagicOnion/issues/296)) + +> **NOTE**: gRPC native library for iOS has a file size of over 100MB, which may cause problems when pushing to GitHub or others. For more information on solutions, see [Stripping debug symbols from ios/libgrpc.a](#stripping-debug-symbols-from-ioslibgrpca). + +### MessagePack for C# +MessagePack for C# is not included in MagicOnion package. You need to download and install separately. + +See [MessagePack for C# installation for Unity](https://github.com/neuecc/MessagePack-CSharp#unity) for details. + +### Works with IL2CPP + +If your project uses IL2CPP as a scripting backend, additional setup will be required. See [Ahead-of-Time compilation support with Source Generator](#ahead-of-time-compilation-support-with-source-generator) section for details. ### gRPC channel management integration for Unity Wraps gRPC channels and provides a mechanism to manage them with Unity's lifecycle. From 2b46f4862cb1362fbfb9a8ec429557e0e7616dec Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 24 Oct 2023 10:55:15 +0900 Subject: [PATCH 56/66] Move types and rename namespaces --- .../MagicOnion.Client.SourceGenerator.Unity.csproj | 6 +++--- .../CodeAnalysis/MagicOnionTypeInfo.cs | 1 - .../CodeAnalysis/MethodCollector.cs | 2 -- .../{Utils => Helpers}/RoslynExtensions.cs | 3 ++- .../{Utils => Helpers}/TypeExtensions.cs | 3 ++- ...r.Emit.cs => MagicOnionClientSourceGenerator.Emitter.cs} | 0 ...r.Parse.cs => MagicOnionClientSourceGenerator.Parser.cs} | 1 - 7 files changed, 7 insertions(+), 9 deletions(-) rename src/MagicOnion.Client.SourceGenerator/{Utils => Helpers}/RoslynExtensions.cs (93%) rename src/MagicOnion.Client.SourceGenerator/{Utils => Helpers}/TypeExtensions.cs (93%) rename src/MagicOnion.Client.SourceGenerator/{MagicOnionClientSourceGenerator.Emit.cs => MagicOnionClientSourceGenerator.Emitter.cs} (100%) rename src/MagicOnion.Client.SourceGenerator/{MagicOnionClientSourceGenerator.Parse.cs => MagicOnionClientSourceGenerator.Parser.cs} (99%) diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj index 6e3168277..7c360b7f9 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -18,12 +18,12 @@ + - - - + + diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs index bc4afcde8..7398cf074 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using MagicOnion.Client.SourceGenerator.Utils; using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index 98120e86a..0d0c02c56 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -1,8 +1,6 @@ using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; -using System.Threading; using MagicOnion.Client.SourceGenerator.Internal; -using MagicOnion.Client.SourceGenerator.Utils; using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator.CodeAnalysis; diff --git a/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Helpers/RoslynExtensions.cs similarity index 93% rename from src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs rename to src/MagicOnion.Client.SourceGenerator/Helpers/RoslynExtensions.cs index bcfeedc1c..9868a888d 100644 --- a/src/MagicOnion.Client.SourceGenerator/Utils/RoslynExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/Helpers/RoslynExtensions.cs @@ -1,6 +1,7 @@ using Microsoft.CodeAnalysis; -namespace MagicOnion.Client.SourceGenerator.Utils; +// ReSharper disable once CheckNamespace +namespace MagicOnion.Client.SourceGenerator; // Utility and Extension methods for Roslyn internal static class RoslynExtensions diff --git a/src/MagicOnion.Client.SourceGenerator/Utils/TypeExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Helpers/TypeExtensions.cs similarity index 93% rename from src/MagicOnion.Client.SourceGenerator/Utils/TypeExtensions.cs rename to src/MagicOnion.Client.SourceGenerator/Helpers/TypeExtensions.cs index 4dc59a07f..40696ff0c 100644 --- a/src/MagicOnion.Client.SourceGenerator/Utils/TypeExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/Helpers/TypeExtensions.cs @@ -1,6 +1,7 @@ using Microsoft.CodeAnalysis; -namespace MagicOnion.Client.SourceGenerator.Utils; +// ReSharper disable once CheckNamespace +namespace MagicOnion.Client.SourceGenerator; internal static class TypeExtensions { diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs similarity index 100% rename from src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emit.cs rename to src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Parse.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Parser.cs similarity index 99% rename from src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Parse.cs rename to src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Parser.cs index 61bafab74..e56b78ca8 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Parse.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Parser.cs @@ -1,7 +1,6 @@ using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; using MagicOnion.Client.SourceGenerator.CodeAnalysis; -using MagicOnion.Client.SourceGenerator.Utils; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; From 44612cf46e4973f88d99a62bc626b94edd54621d Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 24 Oct 2023 10:59:59 +0900 Subject: [PATCH 57/66] Remove MagicOnionClientGenerator --- ...cOnion.Client.SourceGenerator.Unity.csproj | 1 - ...MagicOnionClientSourceGenerator.Roslyn3.cs | 2 +- .../MagicOnionClientGenerator.cs | 69 ------------------- ...MagicOnionClientSourceGenerator.Emitter.cs | 67 ++++++++++++++++-- .../MagicOnionClientSourceGenerator.cs | 2 +- 5 files changed, 64 insertions(+), 77 deletions(-) delete mode 100644 src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj index 7c360b7f9..a4014502c 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.csproj @@ -21,7 +21,6 @@ - diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs index e30718f4e..1a2b72aa6 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs @@ -36,7 +36,7 @@ public void Execute(GeneratorExecutionContext context) } var generationContext = new GenerationContext(spec.InitializerPartialTypeNamespace, spec.InitializerPartialTypeName, sourceProductionContext, options); - Generate(generationContext, spec.InterfaceSymbols, referenceSymbols); + Emit(generationContext, spec.InterfaceSymbols, referenceSymbols); } } } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs deleted file mode 100644 index f8683f14f..000000000 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientGenerator.cs +++ /dev/null @@ -1,69 +0,0 @@ -using MagicOnion.Client.SourceGenerator.CodeAnalysis; -using MagicOnion.Client.SourceGenerator.CodeGen; -using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; - -namespace MagicOnion.Client.SourceGenerator; - -public static class MagicOnionClientGenerator -{ - public static IReadOnlyList<(string Path, string Source)> Generate(GenerationContext context, MagicOnionServiceCollection serviceCollection, CancellationToken cancellationToken) - { - var outputs = new List<(string Path, string Source)>(); - - // Configure serialization - (ISerializationFormatterNameMapper Mapper, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) - serialization = context.Options.Serializer switch - { - SerializerType.MemoryPack => ( - Mapper: new MemoryPackFormatterNameMapper(), - Generator: new MemoryPackFormatterRegistrationGenerator(), - EnumFormatterGenerator: _ => string.Empty - ), - SerializerType.MessagePack => ( - Mapper: new MessagePackFormatterNameMapper(context.Options.MessagePackFormatterNamespace), - Generator: new MessagePackFormatterResolverGenerator(), - EnumFormatterGenerator: x => MessagePackEnumFormatterGenerator.Build(context, x) - ), - _ => throw new NotImplementedException(), - }; - - cancellationToken.ThrowIfCancellationRequested(); - - var serializationInfoCollector = new SerializationInfoCollector(serialization.Mapper); - var serializationInfoCollection = serializationInfoCollector.Collect(serviceCollection); - - cancellationToken.ThrowIfCancellationRequested(); - - var formatterCodeGenContext = new SerializationFormatterCodeGenContext(context.Namespace ?? string.Empty, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); - var resolverTexts = serialization.Generator.Build(context, formatterCodeGenContext); - - cancellationToken.ThrowIfCancellationRequested(); - - outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName), MagicOnionInitializerGenerator.Build(context, serviceCollection))); - outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".Resolver"), resolverTexts)); - - if (serializationInfoCollection.Enums.Any()) - { - outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".EnumFormatters"), serialization.EnumFormatterGenerator(serializationInfoCollection.Enums))); - } - - foreach (var service in serviceCollection.Services) - { - var x = StaticMagicOnionClientGenerator.Build(context, new[] { service }); - outputs.Add((GeneratePathFromNamespaceAndTypeName(service.ServiceType.Namespace, service.GetClientName()), x)); - } - - foreach (var hub in serviceCollection.Hubs) - { - var x = StaticStreamingHubClientGenerator.Build(context, new [] { hub }); - outputs.Add((GeneratePathFromNamespaceAndTypeName(hub.ServiceType.Namespace, hub.GetClientName()), x)); - } - - return outputs.OrderBy(x => x.Path).ToArray(); - } - - static string GeneratePathFromNamespaceAndTypeName(string ns, string className) - { - return $"{ns}_{className}".Replace(".", "_").Replace("global::", string.Empty) + ".g.cs"; - } -} diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs index a14b65cde..882eee696 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs @@ -1,5 +1,7 @@ using System.Collections.Immutable; using MagicOnion.Client.SourceGenerator.CodeAnalysis; +using MagicOnion.Client.SourceGenerator.CodeGen; +using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator; @@ -58,16 +60,71 @@ internal enum GenerateSerializerType """); } - static void Generate(GenerationContext context, ImmutableArray interfaces, Compilation compilation, ReferenceSymbols referenceSymbols) + static IReadOnlyList<(string Path, string Source)> Emit(GenerationContext context, MagicOnionServiceCollection serviceCollection, CancellationToken cancellationToken) { - var interfaceSymbols = interfaces.Select(x => (INamedTypeSymbol)compilation.GetSemanticModel(x.SyntaxTree).GetDeclaredSymbol(x)!).ToImmutableArray(); - Generate(context, interfaceSymbols, referenceSymbols); + var outputs = new List<(string Path, string Source)>(); + + // Configure serialization + (ISerializationFormatterNameMapper Mapper, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) + serialization = context.Options.Serializer switch + { + SerializerType.MemoryPack => ( + Mapper: new MemoryPackFormatterNameMapper(), + Generator: new MemoryPackFormatterRegistrationGenerator(), + EnumFormatterGenerator: _ => string.Empty + ), + SerializerType.MessagePack => ( + Mapper: new MessagePackFormatterNameMapper(context.Options.MessagePackFormatterNamespace), + Generator: new MessagePackFormatterResolverGenerator(), + EnumFormatterGenerator: x => MessagePackEnumFormatterGenerator.Build(context, x) + ), + _ => throw new NotImplementedException(), + }; + + cancellationToken.ThrowIfCancellationRequested(); + + var serializationInfoCollector = new SerializationInfoCollector(serialization.Mapper); + var serializationInfoCollection = serializationInfoCollector.Collect(serviceCollection); + + cancellationToken.ThrowIfCancellationRequested(); + + var formatterCodeGenContext = new SerializationFormatterCodeGenContext(context.Namespace ?? string.Empty, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); + var resolverTexts = serialization.Generator.Build(context, formatterCodeGenContext); + + cancellationToken.ThrowIfCancellationRequested(); + + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName), MagicOnionInitializerGenerator.Build(context, serviceCollection))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".Resolver"), resolverTexts)); + + if (serializationInfoCollection.Enums.Any()) + { + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".EnumFormatters"), serialization.EnumFormatterGenerator(serializationInfoCollection.Enums))); + } + + foreach (var service in serviceCollection.Services) + { + var x = StaticMagicOnionClientGenerator.Build(context, new[] { service }); + outputs.Add((GeneratePathFromNamespaceAndTypeName(service.ServiceType.Namespace, service.GetClientName()), x)); + } + + foreach (var hub in serviceCollection.Hubs) + { + var x = StaticStreamingHubClientGenerator.Build(context, new [] { hub }); + outputs.Add((GeneratePathFromNamespaceAndTypeName(hub.ServiceType.Namespace, hub.GetClientName()), x)); + } + + return outputs.OrderBy(x => x.Path).ToArray(); + } + + static string GeneratePathFromNamespaceAndTypeName(string ns, string className) + { + return $"{ns}_{className}".Replace(".", "_").Replace("global::", string.Empty) + ".g.cs"; } - static void Generate(GenerationContext context, ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) + static void Emit(GenerationContext context, ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) { var (serviceCollection, diagnostics) = MethodCollector.Collect(interfaceSymbols, referenceSymbols, context.SourceProductionContext.CancellationToken); - var generated = MagicOnionClientGenerator.Generate(context, serviceCollection, context.SourceProductionContext.CancellationToken); + var generated = Emit(context, serviceCollection, context.SourceProductionContext.CancellationToken); foreach (var diagnostic in diagnostics) { diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 83d43a4e8..198e53670 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -34,7 +34,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) } var generationContext = new GenerationContext(spec.InitializerPartialTypeNamespace, spec.InitializerPartialTypeName, sourceProductionContext, options); - Generate(generationContext, spec.InterfaceSymbols, referenceSymbols); + Emit(generationContext, spec.InterfaceSymbols, referenceSymbols); }); } } From 4a83ecaf15c4d0df11dcd5cd6a5826911900f3dd Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 24 Oct 2023 11:13:27 +0900 Subject: [PATCH 58/66] Refactor --- ...MagicOnionClientSourceGenerator.Roslyn3.cs | 4 +- .../MagicOnionHubMethodInfoExtensions.cs | 66 ------ ...MagicOnionMethodParameterInfoExtensions.cs | 3 +- .../MagicOnionServiceInfoExtensions.cs | 3 +- .../CodeGen/MagicOnionInitializerGenerator.cs | 1 - ...emoryPackFormatterRegistrationGenerator.cs | 4 +- .../MessagePackEnumFormatterGenerator.cs | 2 +- .../MessagePackFormatterResolverGenerator.cs | 2 +- .../StaticMagicOnionClientGenerator.cs | 3 - .../StaticStreamingHubClientGenerator.cs | 12 +- ...MagicOnionClientSourceGenerator.Emitter.cs | 196 +++++++++--------- .../MagicOnionClientSourceGenerator.cs | 4 +- 12 files changed, 115 insertions(+), 185 deletions(-) delete mode 100644 src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionHubMethodInfoExtensions.cs rename src/MagicOnion.Client.SourceGenerator/CodeGen/{ => MemoryPack}/MemoryPackFormatterRegistrationGenerator.cs (96%) rename src/MagicOnion.Client.SourceGenerator/CodeGen/{ => MessagePack}/MessagePackEnumFormatterGenerator.cs (97%) rename src/MagicOnion.Client.SourceGenerator/CodeGen/{ => MessagePack}/MessagePackFormatterResolverGenerator.cs (99%) diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs index 1a2b72aa6..513154167 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs @@ -10,7 +10,7 @@ public partial class MagicOnionClientSourceGenerator : ISourceGenerator public void Initialize(GeneratorInitializationContext context) { context.RegisterForSyntaxNotifications(static () => new SyntaxContextReceiver()); - context.RegisterForPostInitialization(static context => AddAttributeSources(context.AddSource)); + context.RegisterForPostInitialization(static context => Emitter.AddAttributeSources(context.AddSource)); } public void Execute(GeneratorExecutionContext context) @@ -36,7 +36,7 @@ public void Execute(GeneratorExecutionContext context) } var generationContext = new GenerationContext(spec.InitializerPartialTypeNamespace, spec.InitializerPartialTypeName, sourceProductionContext, options); - Emit(generationContext, spec.InterfaceSymbols, referenceSymbols); + Emitter.Emit(generationContext, spec.InterfaceSymbols, referenceSymbols); } } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionHubMethodInfoExtensions.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionHubMethodInfoExtensions.cs deleted file mode 100644 index 0e8b1080b..000000000 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionHubMethodInfoExtensions.cs +++ /dev/null @@ -1,66 +0,0 @@ -using MagicOnion.Client.SourceGenerator.CodeAnalysis; - -namespace MagicOnion.Client.SourceGenerator.CodeGen.Extensions; - -public static class MagicOnionHubMethodInfoExtensions -{ - public static string ToMethodSignature(this MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo methodInfo) - => $"public {methodInfo.MethodReturnType.FullName} {methodInfo.MethodName}({string.Join(", ", methodInfo.Parameters.Select(x => $"{x.Type.FullName} {x.Name}"))})"; - - public static string ToHubFireAndForgetWriteMessage(this MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo methodInfo) - { - var requestObject = methodInfo.Parameters.Count == 0 - ? "global::MessagePack.Nil.Default" - : methodInfo.Parameters.Count == 1 - ? methodInfo.Parameters[0].Name - : $"new global::MagicOnion.DynamicArgumentTuple<{string.Join(", ", methodInfo.Parameters.Select(x => x.Type.FullName))}>({string.Join(", ", methodInfo.Parameters.Select(x => x.Name))})"; - - return $"WriteMessageWithResponseAsync<{methodInfo.RequestType.FullName}, {methodInfo.ResponseType.FullName}>({methodInfo.HubId}, {requestObject})"; - } - - public static string ToHubWriteMessage(this MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo methodInfo) - { - var requestObject = methodInfo.Parameters.Count == 0 - ? "global::MessagePack.Nil.Default" - : methodInfo.Parameters.Count == 1 - ? methodInfo.Parameters[0].Name - : $"new global::MagicOnion.DynamicArgumentTuple<{string.Join(", ", methodInfo.Parameters.Select(x => x.Type.FullName))}>({string.Join(", ", methodInfo.Parameters.Select(x => x.Name))})"; - - return $"WriteMessageWithResponseAsync<{methodInfo.RequestType.FullName}, {methodInfo.ResponseType.FullName}>({methodInfo.HubId}, {requestObject})"; - } - - public static (string line1, string line2) ToHubOnBroadcastMessage(this MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo methodInfo) - { - string parameterType; - string line2; - if (methodInfo.Parameters.Count == 0) - { - parameterType = "global::MessagePack.Nil"; - line2 = $"{methodInfo.MethodName}()"; - } - else if (methodInfo.Parameters.Count == 1) - { - parameterType = methodInfo.Parameters[0].Type.FullName; - line2 = $"{methodInfo.MethodName}(result)"; - } - else - { - var typeArgs = string.Join(", ", methodInfo.Parameters.Select(x => x.Type.FullName)); - parameterType = $"global::MagicOnion.DynamicArgumentTuple<{typeArgs}>"; - line2 = string.Join(", ", Enumerable.Range(1, methodInfo.Parameters.Count).Select(x => $"result.Item{x}")); - line2 = $"{methodInfo.MethodName}({line2})"; - } - - line2 = "receiver." + line2 + "; break;"; - - var line1 = $"var result = MessagePackSerializer.Deserialize<{parameterType}>(data, serializerOptions);"; - return (line1, line2); - } - - public static (string line1, string line2) ToHubOnResponseEvent(this MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo methodInfo) - { - var line1 = $"var result = MessagePackSerializer.Deserialize<{methodInfo.ResponseType.FullName}>(data, serializerOptions);"; - var line2 = $"((TaskCompletionSource<{methodInfo.ResponseType.FullName}>)taskCompletionSource).TrySetResult(result);"; - return (line1, line2); - } -} diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionMethodParameterInfoExtensions.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionMethodParameterInfoExtensions.cs index a7d572c7b..ccc5d2821 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionMethodParameterInfoExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionMethodParameterInfoExtensions.cs @@ -1,6 +1,7 @@ using MagicOnion.Client.SourceGenerator.CodeAnalysis; -namespace MagicOnion.Client.SourceGenerator.CodeGen.Extensions; +// ReSharper disable once CheckNamespace +namespace MagicOnion.Client.SourceGenerator.CodeGen; public static class MagicOnionMethodParameterInfoExtensions { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs index 150dc27cb..b909aa5e2 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/Extensions/MagicOnionServiceInfoExtensions.cs @@ -1,6 +1,7 @@ using MagicOnion.Client.SourceGenerator.CodeAnalysis; -namespace MagicOnion.Client.SourceGenerator.CodeGen.Extensions; +// ReSharper disable once CheckNamespace +namespace MagicOnion.Client.SourceGenerator.CodeGen; public static class MagicOnionServiceInfoExtensions { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs index 6bb6b8412..100a5a2f2 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs @@ -1,5 +1,4 @@ using MagicOnion.Client.SourceGenerator.CodeAnalysis; -using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; namespace MagicOnion.Client.SourceGenerator.CodeGen; diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPack/MemoryPackFormatterRegistrationGenerator.cs similarity index 96% rename from src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs rename to src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPack/MemoryPackFormatterRegistrationGenerator.cs index 1aa00374a..f2b6e5e40 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPackFormatterRegistrationGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPack/MemoryPackFormatterRegistrationGenerator.cs @@ -1,6 +1,4 @@ -using MagicOnion.Client.SourceGenerator.Internal; - -namespace MagicOnion.Client.SourceGenerator.CodeGen; +namespace MagicOnion.Client.SourceGenerator.CodeGen.MemoryPack; internal class MemoryPackFormatterRegistrationGenerator : ISerializerFormatterGenerator { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackEnumFormatterGenerator.cs similarity index 97% rename from src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs rename to src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackEnumFormatterGenerator.cs index baf9cbe0b..909cfc8f3 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackEnumFormatterGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackEnumFormatterGenerator.cs @@ -1,6 +1,6 @@ using MagicOnion.Client.SourceGenerator.CodeAnalysis; -namespace MagicOnion.Client.SourceGenerator.CodeGen; +namespace MagicOnion.Client.SourceGenerator.CodeGen.MessagePack; internal class MessagePackEnumFormatterGenerator { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackFormatterResolverGenerator.cs similarity index 99% rename from src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs rename to src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackFormatterResolverGenerator.cs index 351557438..d9188e709 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePackFormatterResolverGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackFormatterResolverGenerator.cs @@ -1,6 +1,6 @@ using MagicOnion.Client.SourceGenerator.CodeAnalysis; -namespace MagicOnion.Client.SourceGenerator.CodeGen; +namespace MagicOnion.Client.SourceGenerator.CodeGen.MessagePack; internal class MessagePackFormatterResolverGenerator : ISerializerFormatterGenerator { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs index a0ca2e0ac..ffacdf45b 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs @@ -1,7 +1,4 @@ -using System.CodeDom.Compiler; using MagicOnion.Client.SourceGenerator.CodeAnalysis; -using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; -using MagicOnion.Client.SourceGenerator.Internal; namespace MagicOnion.Client.SourceGenerator.CodeGen; diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs index d5c11df28..9ac4a5be1 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs @@ -1,7 +1,4 @@ -using System.CodeDom.Compiler; using MagicOnion.Client.SourceGenerator.CodeAnalysis; -using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; -using MagicOnion.Client.SourceGenerator.Internal; namespace MagicOnion.Client.SourceGenerator.CodeGen; @@ -22,8 +19,7 @@ public StreamingHubClientBuildContext(MagicOnionStreamingHubInfo hub, TextWriter public static string Build(GenerationContext generationContext, IEnumerable hubs) { - var baseWriter = new StringWriter(); - var textWriter = new IndentedTextWriter(baseWriter); + var textWriter = new StringWriter(); EmitHeader(generationContext, textWriter); @@ -36,12 +32,12 @@ public static string Build(GenerationContext generationContext, IEnumerable #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs index 882eee696..bdbce3898 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs @@ -1,7 +1,8 @@ using System.Collections.Immutable; using MagicOnion.Client.SourceGenerator.CodeAnalysis; using MagicOnion.Client.SourceGenerator.CodeGen; -using MagicOnion.Client.SourceGenerator.CodeGen.Extensions; +using MagicOnion.Client.SourceGenerator.CodeGen.MemoryPack; +using MagicOnion.Client.SourceGenerator.CodeGen.MessagePack; using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator; @@ -12,128 +13,131 @@ public partial class MagicOnionClientSourceGenerator public const string MagicOnionClientGenerationAttributeName = "MagicOnionClientGenerationAttribute"; public const string MagicOnionClientGenerationAttributeFullName = $"MagicOnion.Client.{MagicOnionClientGenerationAttributeName}"; - static void AddAttributeSources(Action addSource) + static class Emitter { - addSource(SourceGeneratorAttributesHintName, $$""" - // - namespace MagicOnion.Client - { - /// - /// Marker attribute for generating clients of MagicOnion. - /// The source generator collects the classes specified by this attribute and uses them to generate source. - /// - [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] - [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] - internal class {{MagicOnionClientGenerationAttributeName}} : global::System.Attribute + public static void AddAttributeSources(Action addSource) + { + addSource(SourceGeneratorAttributesHintName, $$""" + // + namespace MagicOnion.Client { /// - /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) - /// - public bool DisableAutoRegistration { get; set; } - - /// - /// Gets or set the serializer used for message serialization. The default value is . + /// Marker attribute for generating clients of MagicOnion. + /// The source generator collects the classes specified by this attribute and uses them to generate source. /// - public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; - - /// - /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. - /// - public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; + [global::System.Diagnostics.Conditional("__MagicOnion_Client_SourceGenerator__DesignTimeOnly__")] + [global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false)] + internal class {{MagicOnionClientGenerationAttributeName}} : global::System.Attribute + { + /// + /// Gets or sets whether to disable automatically calling `Register` during start-up. (Automatic registration requires .NET 5+ or Unity) + /// + public bool DisableAutoRegistration { get; set; } + + /// + /// Gets or set the serializer used for message serialization. The default value is . + /// + public global::MagicOnion.Client.GenerateSerializerType Serializer { get; set; } = global::MagicOnion.Client.GenerateSerializerType.MessagePack; + + /// + /// Gets or set the namespace of pre-generated MessagePackFormatters. The default value is MessagePack.Formatters. + /// + public string MessagePackFormatterNamespace { get; set; } = "MessagePack.Formatters"; + + public global::System.Type[] TypesContainedInTargetAssembly { get; } + + /// Types contained in the scan target assembly + public {{MagicOnionClientGenerationAttributeName}}(params global::System.Type[] typesContainedInTargetAssembly) + { + TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + } + } - public global::System.Type[] TypesContainedInTargetAssembly { get; } - - /// Types contained in the scan target assembly - public {{MagicOnionClientGenerationAttributeName}}(params global::System.Type[] typesContainedInTargetAssembly) + // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) + internal enum GenerateSerializerType { - TypesContainedInTargetAssembly = typesContainedInTargetAssembly; + MessagePack = 0, + MemoryPack = 1, } } + """); + } - // This enum must be mirror of `SerializerType` (MagicOnionClientSourceGenerator) - internal enum GenerateSerializerType - { - MessagePack = 0, - MemoryPack = 1, - } + public static void Emit(GenerationContext context, ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) + { + var (serviceCollection, diagnostics) = MethodCollector.Collect(interfaceSymbols, referenceSymbols, context.SourceProductionContext.CancellationToken); + var generated = EmitCore(context, serviceCollection, context.SourceProductionContext.CancellationToken); + + foreach (var diagnostic in diagnostics) + { + context.SourceProductionContext.ReportDiagnostic(diagnostic); } - """); - } - static IReadOnlyList<(string Path, string Source)> Emit(GenerationContext context, MagicOnionServiceCollection serviceCollection, CancellationToken cancellationToken) - { - var outputs = new List<(string Path, string Source)>(); + foreach (var (path, source) in generated) + { + context.SourceProductionContext.AddSource(path, source); + } + } - // Configure serialization - (ISerializationFormatterNameMapper Mapper, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) - serialization = context.Options.Serializer switch + static IReadOnlyList<(string Path, string Source)> EmitCore(GenerationContext context, MagicOnionServiceCollection serviceCollection, CancellationToken cancellationToken) { - SerializerType.MemoryPack => ( - Mapper: new MemoryPackFormatterNameMapper(), - Generator: new MemoryPackFormatterRegistrationGenerator(), - EnumFormatterGenerator: _ => string.Empty - ), - SerializerType.MessagePack => ( - Mapper: new MessagePackFormatterNameMapper(context.Options.MessagePackFormatterNamespace), - Generator: new MessagePackFormatterResolverGenerator(), - EnumFormatterGenerator: x => MessagePackEnumFormatterGenerator.Build(context, x) - ), - _ => throw new NotImplementedException(), - }; + var outputs = new List<(string Path, string Source)>(); - cancellationToken.ThrowIfCancellationRequested(); - - var serializationInfoCollector = new SerializationInfoCollector(serialization.Mapper); - var serializationInfoCollection = serializationInfoCollector.Collect(serviceCollection); - - cancellationToken.ThrowIfCancellationRequested(); + // Configure serialization + (ISerializationFormatterNameMapper Mapper, ISerializerFormatterGenerator Generator, Func, string> EnumFormatterGenerator) + serialization = context.Options.Serializer switch + { + SerializerType.MemoryPack => ( + Mapper: new MemoryPackFormatterNameMapper(), + Generator: new MemoryPackFormatterRegistrationGenerator(), + EnumFormatterGenerator: _ => string.Empty + ), + SerializerType.MessagePack => ( + Mapper: new MessagePackFormatterNameMapper(context.Options.MessagePackFormatterNamespace), + Generator: new MessagePackFormatterResolverGenerator(), + EnumFormatterGenerator: x => MessagePackEnumFormatterGenerator.Build(context, x) + ), + _ => throw new NotImplementedException(), + }; - var formatterCodeGenContext = new SerializationFormatterCodeGenContext(context.Namespace ?? string.Empty, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); - var resolverTexts = serialization.Generator.Build(context, formatterCodeGenContext); + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + var serializationInfoCollector = new SerializationInfoCollector(serialization.Mapper); + var serializationInfoCollection = serializationInfoCollector.Collect(serviceCollection); - outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName), MagicOnionInitializerGenerator.Build(context, serviceCollection))); - outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".Resolver"), resolverTexts)); + cancellationToken.ThrowIfCancellationRequested(); - if (serializationInfoCollection.Enums.Any()) - { - outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".EnumFormatters"), serialization.EnumFormatterGenerator(serializationInfoCollection.Enums))); - } + var formatterCodeGenContext = new SerializationFormatterCodeGenContext(context.Namespace ?? string.Empty, serializationInfoCollection.RequireRegistrationFormatters, serializationInfoCollection.TypeHints); + var resolverTexts = serialization.Generator.Build(context, formatterCodeGenContext); - foreach (var service in serviceCollection.Services) - { - var x = StaticMagicOnionClientGenerator.Build(context, new[] { service }); - outputs.Add((GeneratePathFromNamespaceAndTypeName(service.ServiceType.Namespace, service.GetClientName()), x)); - } + cancellationToken.ThrowIfCancellationRequested(); - foreach (var hub in serviceCollection.Hubs) - { - var x = StaticStreamingHubClientGenerator.Build(context, new [] { hub }); - outputs.Add((GeneratePathFromNamespaceAndTypeName(hub.ServiceType.Namespace, hub.GetClientName()), x)); - } + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName), MagicOnionInitializerGenerator.Build(context, serviceCollection))); + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".Resolver"), resolverTexts)); - return outputs.OrderBy(x => x.Path).ToArray(); - } + if (serializationInfoCollection.Enums.Any()) + { + outputs.Add((GeneratePathFromNamespaceAndTypeName(context.Namespace ?? string.Empty, context.InitializerPartialTypeName + ".EnumFormatters"), serialization.EnumFormatterGenerator(serializationInfoCollection.Enums))); + } - static string GeneratePathFromNamespaceAndTypeName(string ns, string className) - { - return $"{ns}_{className}".Replace(".", "_").Replace("global::", string.Empty) + ".g.cs"; - } + foreach (var service in serviceCollection.Services) + { + var x = StaticMagicOnionClientGenerator.Build(context, new[] { service }); + outputs.Add((GeneratePathFromNamespaceAndTypeName(service.ServiceType.Namespace, service.GetClientName()), x)); + } - static void Emit(GenerationContext context, ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols) - { - var (serviceCollection, diagnostics) = MethodCollector.Collect(interfaceSymbols, referenceSymbols, context.SourceProductionContext.CancellationToken); - var generated = Emit(context, serviceCollection, context.SourceProductionContext.CancellationToken); + foreach (var hub in serviceCollection.Hubs) + { + var x = StaticStreamingHubClientGenerator.Build(context, new [] { hub }); + outputs.Add((GeneratePathFromNamespaceAndTypeName(hub.ServiceType.Namespace, hub.GetClientName()), x)); + } - foreach (var diagnostic in diagnostics) - { - context.SourceProductionContext.ReportDiagnostic(diagnostic); + return outputs.OrderBy(x => x.Path).ToArray(); } - foreach (var (path, source) in generated) + static string GeneratePathFromNamespaceAndTypeName(string ns, string className) { - context.SourceProductionContext.AddSource(path, source); + return $"{ns}_{className}".Replace(".", "_").Replace("global::", string.Empty) + ".g.cs"; } } } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs index 198e53670..d6a90418f 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.cs @@ -17,7 +17,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) predicate: static (node, cancellationToken) => node is ClassDeclarationSyntax, transform: static (ctx, cancellationToken) => ((ClassDeclarationSyntax)ctx.TargetNode, ctx.Attributes, ctx.SemanticModel)); - context.RegisterPostInitializationOutput(static context => AddAttributeSources(context.AddSource)); + context.RegisterPostInitializationOutput(static context => Emitter.AddAttributeSources(context.AddSource)); context.RegisterSourceOutput(generationAttr.Combine(referenceSymbols), static (sourceProductionContext, value) => { @@ -34,7 +34,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) } var generationContext = new GenerationContext(spec.InitializerPartialTypeNamespace, spec.InitializerPartialTypeName, sourceProductionContext, options); - Emit(generationContext, spec.InterfaceSymbols, referenceSymbols); + Emitter.Emit(generationContext, spec.InterfaceSymbols, referenceSymbols); }); } } From 466a8a0b6b6df24a2c254ef01487b351ac66fa72 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 24 Oct 2023 11:14:54 +0900 Subject: [PATCH 59/66] Remove unused codes --- .../Internal/IndentedTextWriterExtensions.cs | 37 ------------------- .../Internal/SyntaxHelper.cs | 12 ------ 2 files changed, 49 deletions(-) delete mode 100644 src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs delete mode 100644 src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs diff --git a/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs deleted file mode 100644 index 2bd97adf8..000000000 --- a/src/MagicOnion.Client.SourceGenerator/Internal/IndentedTextWriterExtensions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.CodeDom.Compiler; - -namespace MagicOnion.Client.SourceGenerator.Internal; - -internal static class IndentedTextWriterExtensions -{ - public static void WriteLines(this IndentedTextWriter writer, string lines) - { - foreach (var line in lines.Split('\n')) - { - writer.WriteLine(line.TrimEnd()); - } - } - - public static IndentedBlock BeginIndent(this IndentedTextWriter textWriter, int depth = 1) - { - textWriter.Indent += depth; - return new IndentedBlock(textWriter, depth); - } - - public readonly struct IndentedBlock : IDisposable - { - readonly IndentedTextWriter textWriter; - readonly int depth; - - public IndentedBlock(IndentedTextWriter textWriter, int depth) - { - this.textWriter = textWriter; - this.depth = depth; - } - - public void Dispose() - { - textWriter.Indent -= depth; - } - } -} diff --git a/src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs b/src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs deleted file mode 100644 index fd676c16d..000000000 --- a/src/MagicOnion.Client.SourceGenerator/Internal/SyntaxHelper.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis; - -namespace MagicOnion.Client.SourceGenerator.Internal; - -internal static class SyntaxHelper -{ - public static bool IsCandidateInterface(SyntaxNode node) - => node is InterfaceDeclarationSyntax interfaceDeclaration && - (interfaceDeclaration.BaseList?.Types.Any() ?? false); -} - From 88af79885df28e4717fe481f635214b4bceea7b4 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 24 Oct 2023 11:21:25 +0900 Subject: [PATCH 60/66] Refactor --- .../CodeGen/StaticMagicOnionClientGenerator.cs | 13 +++++-------- .../CodeGen/StaticStreamingHubClientGenerator.cs | 13 +++++-------- .../MagicOnionClientSourceGenerator.Emitter.cs | 4 ++-- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs index ffacdf45b..aa841fb57 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs @@ -17,20 +17,17 @@ public ServiceClientBuildContext(MagicOnionServiceInfo service, TextWriter textW public TextWriter TextWriter { get; } } - public static string Build(GenerationContext generationContext, IEnumerable services) + public static string Build(GenerationContext generationContext, MagicOnionServiceInfo serviceInfo) { var textWriter = new StringWriter(); EmitHeader(generationContext, textWriter); - foreach (var serviceInfo in services) - { - var buildContext = new ServiceClientBuildContext(serviceInfo, textWriter); + var buildContext = new ServiceClientBuildContext(serviceInfo, textWriter); - EmitPreamble(generationContext, buildContext); - EmitServiceClientClass(generationContext, buildContext); - EmitPostscript(generationContext, buildContext); - } + EmitPreamble(generationContext, buildContext); + EmitServiceClientClass(generationContext, buildContext); + EmitPostscript(generationContext, buildContext); return textWriter.ToString(); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs index 9ac4a5be1..444b42a6d 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs @@ -17,20 +17,17 @@ public StreamingHubClientBuildContext(MagicOnionStreamingHubInfo hub, TextWriter public TextWriter TextWriter { get; } } - public static string Build(GenerationContext generationContext, IEnumerable hubs) + public static string Build(GenerationContext generationContext, MagicOnionStreamingHubInfo hubInfo) { var textWriter = new StringWriter(); EmitHeader(generationContext, textWriter); - foreach (var hubInfo in hubs) - { - var buildContext = new StreamingHubClientBuildContext(hubInfo, textWriter); + var buildContext = new StreamingHubClientBuildContext(hubInfo, textWriter); - EmitPreamble(generationContext, buildContext); - EmitHubClientClass(generationContext, buildContext); - EmitPostscript(generationContext, buildContext); - } + EmitPreamble(generationContext, buildContext); + EmitHubClientClass(generationContext, buildContext); + EmitPostscript(generationContext, buildContext); return textWriter.ToString(); } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs index bdbce3898..bf266642a 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs @@ -122,13 +122,13 @@ public static void Emit(GenerationContext context, ImmutableArray Date: Tue, 24 Oct 2023 16:32:19 +0900 Subject: [PATCH 61/66] Reduce allocation during code generation --- MagicOnion.sln | 14 ++- .../SourceGeneratorPerf/CompilationHelper.cs | 41 +++++++++ .../SourceGeneratorPerf/Program.cs | 87 +++++++++++++++++++ .../SourceGeneratorPerf.csproj | 20 +++++ .../MagicOnionMethodParameterInfo.cs | 5 +- .../CodeAnalysis/MagicOnionTypeInfo.cs | 12 ++- .../CodeAnalysis/MethodCollector.cs | 44 ++++++---- .../SerializationInfoCollector.cs | 67 +++++++------- 8 files changed, 227 insertions(+), 63 deletions(-) create mode 100644 perf/SourceGeneratorPerf/SourceGeneratorPerf/CompilationHelper.cs create mode 100644 perf/SourceGeneratorPerf/SourceGeneratorPerf/Program.cs create mode 100644 perf/SourceGeneratorPerf/SourceGeneratorPerf/SourceGeneratorPerf.csproj diff --git a/MagicOnion.sln b/MagicOnion.sln index 3032896d8..1edc75ed7 100644 --- a/MagicOnion.sln +++ b/MagicOnion.sln @@ -104,9 +104,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGenerator.Unity", "src\MagicOnion.Client.SourceGenerator.Unity\MagicOnion.Client.SourceGenerator.Unity.csproj", "{A817FC3D-5C8D-4F47-B082-DB6A8EE227FD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleServiceDefinitions", "tests\samples\SampleServiceDefinitions\SampleServiceDefinitions.csproj", "{45EA8028-41C1-4DF6-9E0F-EEE8967799DA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleServiceDefinitions", "tests\samples\SampleServiceDefinitions\SampleServiceDefinitions.csproj", "{45EA8028-41C1-4DF6-9E0F-EEE8967799DA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicOnion.Client.SourceGenerator.Unity.Tests", "tests\MagicOnion.Client.SourceGenerator.Unity.Tests\MagicOnion.Client.SourceGenerator.Unity.Tests.csproj", "{AFB26C11-0833-459D-B071-7CA001BD7F01}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Client.SourceGenerator.Unity.Tests", "tests\MagicOnion.Client.SourceGenerator.Unity.Tests\MagicOnion.Client.SourceGenerator.Unity.Tests.csproj", "{AFB26C11-0833-459D-B071-7CA001BD7F01}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SourceGeneratorPerf", "SourceGeneratorPerf", "{E9E11DFE-29C4-4933-A21B-2222646D946E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceGeneratorPerf", "perf\SourceGeneratorPerf\SourceGeneratorPerf\SourceGeneratorPerf.csproj", "{7F132098-0C1D-4F3A-B049-ACABF5E35973}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -242,6 +246,10 @@ Global {AFB26C11-0833-459D-B071-7CA001BD7F01}.Debug|Any CPU.Build.0 = Debug|Any CPU {AFB26C11-0833-459D-B071-7CA001BD7F01}.Release|Any CPU.ActiveCfg = Release|Any CPU {AFB26C11-0833-459D-B071-7CA001BD7F01}.Release|Any CPU.Build.0 = Release|Any CPU + {7F132098-0C1D-4F3A-B049-ACABF5E35973}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F132098-0C1D-4F3A-B049-ACABF5E35973}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F132098-0C1D-4F3A-B049-ACABF5E35973}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F132098-0C1D-4F3A-B049-ACABF5E35973}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -284,6 +292,8 @@ Global {A817FC3D-5C8D-4F47-B082-DB6A8EE227FD} = {1987061F-8970-4018-8D58-6932961C9EB4} {45EA8028-41C1-4DF6-9E0F-EEE8967799DA} = {B5617CC1-55FD-4F77-BA75-9450474C6527} {AFB26C11-0833-459D-B071-7CA001BD7F01} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0} + {E9E11DFE-29C4-4933-A21B-2222646D946E} = {A0CED9FB-5B18-4EE3-859F-CE3A6F90A82A} + {7F132098-0C1D-4F3A-B049-ACABF5E35973} = {E9E11DFE-29C4-4933-A21B-2222646D946E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D5B2E7E3-B727-40A1-BE68-7BAC9B9DE2FE} diff --git a/perf/SourceGeneratorPerf/SourceGeneratorPerf/CompilationHelper.cs b/perf/SourceGeneratorPerf/SourceGeneratorPerf/CompilationHelper.cs new file mode 100644 index 000000000..cbb16a199 --- /dev/null +++ b/perf/SourceGeneratorPerf/SourceGeneratorPerf/CompilationHelper.cs @@ -0,0 +1,41 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; + +namespace MagicOnion.Client.SourceGenerator.Tests; + +public static class CompilationHelper +{ + public static (Compilation Compilation, SemanticModel SemanticModel) Create(string code) + { + var syntaxTree = SyntaxFactory.ParseSyntaxTree(code, CSharpParseOptions.Default); + var assemblyName = Guid.NewGuid().ToString(); + var refAsmDir = Path.GetDirectoryName(typeof(object).Assembly.Location)!; + var references = new MetadataReference[] + { + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Private.CoreLib.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.Extensions.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Collections.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Linq.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Console.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Memory.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "netstandard.dll")), + MetadataReference.CreateFromFile(typeof(object).Assembly.Location), + MetadataReference.CreateFromFile(typeof(Grpc.Core.AsyncUnaryCall<>).Assembly.Location), // Grpc.Core.Api + MetadataReference.CreateFromFile(typeof(Grpc.Net.Client.GrpcChannel).Assembly.Location), // Grpc.Net.Client + MetadataReference.CreateFromFile(typeof(MessagePack.MessagePackSerializer).Assembly.Location), // MessagePack + MetadataReference.CreateFromFile(typeof(MessagePack.MessagePackObjectAttribute).Assembly.Location), // MessagePack.Annotations + MetadataReference.CreateFromFile(typeof(MagicOnion.IService<>).Assembly.Location), // MagicOnion.Abstractions + MetadataReference.CreateFromFile(typeof(MagicOnion.Client.MagicOnionClient).Assembly.Location), // MagicOnion.Client + MetadataReference.CreateFromFile(typeof(MagicOnion.GrpcMethodHelper).Assembly.Location), // MagicOnion.Shared + }; + var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); + + var compilation = CSharpCompilation.Create(assemblyName, new [] { syntaxTree }, references, compilationOptions); + //if (compilation.GetDiagnostics().Any(x => x.Severity == DiagnosticSeverity.Error)) + //{ + // throw new InvalidOperationException("Failed to compile the source code. \n" + string.Join(Environment.NewLine, compilation.GetDiagnostics().Select(x => x.ToString()))); + //} + return (compilation, compilation.GetSemanticModel(syntaxTree)); + } +} diff --git a/perf/SourceGeneratorPerf/SourceGeneratorPerf/Program.cs b/perf/SourceGeneratorPerf/SourceGeneratorPerf/Program.cs new file mode 100644 index 000000000..c6d09a93f --- /dev/null +++ b/perf/SourceGeneratorPerf/SourceGeneratorPerf/Program.cs @@ -0,0 +1,87 @@ +using System.Text; +using JetBrains.Profiler.Api; +using MagicOnion.Client.SourceGenerator; +using MagicOnion.Client.SourceGenerator.Tests; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; + +MemoryProfiler.CollectAllocations(true); + + +var sb = new StringBuilder(); +sb.AppendLine(""" + #nullable enable + using System; + using System.Threading.Tasks; + using MagicOnion; + using MagicOnion.Client; + + namespace TempProject; + """); + +for (var i = 0; i < 100; i++) +{ + sb.AppendLine($$""" + public interface IMyStreamingHub{{i}} : IStreamingHub + { + """); + for (var j = 0; j < 10; j++) + { + sb.AppendLine($$""" + Task HelloAsync{{j}}(string name, int age); + """); + } + + sb.AppendLine($$""" + } + public interface IMyStreamingHubReceiver{{i}} + { + """); + for (var j = 0; j < 10; j++) + { + sb.AppendLine($$""" + void Callback{{j}}(string name, int age); + """); + } + + sb.AppendLine($$""" + } + """); + + sb.AppendLine($$""" + public interface IMyService{{i}} : IService + { + """); + for (var j = 0; j < 10; j++) + { + sb.AppendLine($$""" + UnaryResult HelloAsync{{j}}(string name, int age); + """); + } + sb.AppendLine($$""" + } + """); +} +sb.AppendLine(""" + [MagicOnionClientGeneration(typeof(MagicOnionInitializer))] + partial class MagicOnionInitializer {} + """); + +var (compilation, semanticModel) = CompilationHelper.Create(sb.ToString()); +var sourceGenerator = new MagicOnionClientSourceGenerator(); + +GeneratorDriver driver = CSharpGeneratorDriver.Create( + generators: new[] { sourceGenerator.AsSourceGenerator() }, + driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true) +); + +// Run generator and update compilation +MemoryProfiler.GetSnapshot("Before RunGenerators#1"); +driver.RunGenerators(compilation, CancellationToken.None); +MemoryProfiler.GetSnapshot("After RunGenerators#1/Before RunGenerators#2"); +driver = driver.RunGenerators(compilation, CancellationToken.None); +MemoryProfiler.GetSnapshot("After RunGenerators#2/Before RunGenerators#3"); +driver = driver.RunGenerators(compilation, CancellationToken.None); +MemoryProfiler.GetSnapshot("After RunGenerators#3/Before RunGeneratorsAndUpdateCompilation"); +driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var newCompilation, out var diagnostics); +MemoryProfiler.GetSnapshot("After RunGeneratorsAndUpdateCompilation"); diff --git a/perf/SourceGeneratorPerf/SourceGeneratorPerf/SourceGeneratorPerf.csproj b/perf/SourceGeneratorPerf/SourceGeneratorPerf/SourceGeneratorPerf.csproj new file mode 100644 index 000000000..7423efc7d --- /dev/null +++ b/perf/SourceGeneratorPerf/SourceGeneratorPerf/SourceGeneratorPerf.csproj @@ -0,0 +1,20 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + + + + + diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs index 7cc06a9b6..c2685dd1e 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionMethodParameterInfo.cs @@ -19,10 +19,9 @@ public MagicOnionMethodParameterInfo(string name, MagicOnionTypeInfo type, bool DefaultValue = defaultValue; } - public static MagicOnionMethodParameterInfo CreateFromSymbol(IParameterSymbol parameterSymbol) + public static MagicOnionMethodParameterInfo CreateFromTypeInfoAndSymbol(MagicOnionTypeInfo typeInfo, IParameterSymbol parameterSymbol) { - var type = MagicOnionTypeInfo.CreateFromSymbol(parameterSymbol.Type); - return new MagicOnionMethodParameterInfo(parameterSymbol.Name, type, parameterSymbol.HasExplicitDefaultValue, GetDefaultValue(parameterSymbol)); + return new MagicOnionMethodParameterInfo(parameterSymbol.Name, typeInfo, parameterSymbol.HasExplicitDefaultValue, GetDefaultValue(parameterSymbol)); } static string GetDefaultValue(IParameterSymbol p) diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs index 7398cf074..34da33848 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MagicOnionTypeInfo.cs @@ -20,6 +20,8 @@ public static class KnownTypes } readonly SubType subType; + string? fullName; + string? fullNameOpenType; public string Namespace { get; } public string Name { get; } @@ -38,9 +40,9 @@ public MagicOnionTypeInfo GetGenericTypeDefinition() public MagicOnionTypeInfo? ElementType { get; } public string FullName - => ToDisplayName(DisplayNameFormat.FullyQualified); + => fullName ??= ToDisplayName(DisplayNameFormat.FullyQualified); public string FullNameOpenType - => ToDisplayName(DisplayNameFormat.FullyQualified | DisplayNameFormat.OpenGenerics); + => fullNameOpenType ??= ToDisplayName(DisplayNameFormat.FullyQualified | DisplayNameFormat.OpenGenerics); public bool IsValueType => subType == SubType.ValueType || subType == SubType.Enum; @@ -229,7 +231,11 @@ public bool Equals(MagicOnionTypeInfo other) if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; - return FullName == other.FullName && /* Namespace + Name + GenericArguments + ArrayRank + ElementType */ + /* Namespace + Name + GenericArguments + ArrayRank + ElementType */ + return Namespace == other.Namespace && + Name == other.Name && + GenericArguments.SequenceEqual(other.GenericArguments) && + ArrayRank == other.ArrayRank && subType == other.subType && ElementType! == other.ElementType! && UnderlyingType! == other.UnderlyingType!; diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs index 0d0c02c56..0ca6ab8f8 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/MethodCollector.cs @@ -24,7 +24,7 @@ static IReadOnlyList GetStreamingHubs(MethodCollecto { cancellationToken.ThrowIfCancellationRequested(); - var serviceType = MagicOnionTypeInfo.CreateFromSymbol(x); + var serviceType = ctx.GetOrCreateTypeInfoFromSymbol(x); var hasIgnore = HasIgnoreAttribute(x); if (hasIgnore) { @@ -36,7 +36,7 @@ static IReadOnlyList GetStreamingHubs(MethodCollecto foreach (var methodSymbol in x.GetMembers().OfType()) { if (HasIgnoreAttribute(methodSymbol)) continue; - if (TryCreateHubMethodInfoFromMethodSymbol(serviceType, methodSymbol, out var methodInfo, out var diagnostic)) + if (TryCreateHubMethodInfoFromMethodSymbol(ctx, serviceType, methodSymbol, out var methodInfo, out var diagnostic)) { methods.Add(methodInfo); } @@ -52,12 +52,12 @@ static IReadOnlyList GetStreamingHubs(MethodCollecto } var receiverInterfaceSymbol = x.AllInterfaces.First(y => y.ConstructedFrom.ApproximatelyEqual(ctx.ReferenceSymbols.IStreamingHub)).TypeArguments[1]; - var receiverType = MagicOnionTypeInfo.CreateFromSymbol(receiverInterfaceSymbol); + var receiverType = ctx.GetOrCreateTypeInfoFromSymbol(receiverInterfaceSymbol); var receiverMethods = new List(); foreach (var methodSymbol in receiverInterfaceSymbol.GetMembers().OfType()) { - if (TryCreateHubReceiverMethodInfoFromMethodSymbol(serviceType, receiverType, methodSymbol, out var methodInfo, out var diagnostic)) + if (TryCreateHubReceiverMethodInfoFromMethodSymbol(ctx, serviceType, receiverType, methodSymbol, out var methodInfo, out var diagnostic)) { receiverMethods.Add(methodInfo); } @@ -92,11 +92,11 @@ static int GetHubMethodIdFromMethodSymbol(IMethodSymbol methodSymbol) static bool HasIgnoreAttribute(ISymbol symbol) => symbol.GetAttributes().FindAttributeShortName("IgnoreAttribute") is not null; - static bool TryCreateHubMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, IMethodSymbol methodSymbol, [NotNullWhen(true)] out MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo? methodInfo, out Diagnostic? diagnostic) + static bool TryCreateHubMethodInfoFromMethodSymbol(MethodCollectorContext ctx, MagicOnionTypeInfo interfaceType, IMethodSymbol methodSymbol, [NotNullWhen(true)] out MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo? methodInfo, out Diagnostic? diagnostic) { var hubId = GetHubMethodIdFromMethodSymbol(methodSymbol); - var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); - var methodParameters = CreateParameterInfoListFromMethodSymbol(methodSymbol); + var methodReturnType = ctx.GetOrCreateTypeInfoFromSymbol(methodSymbol.ReturnType); + var methodParameters = CreateParameterInfoListFromMethodSymbol(ctx, methodSymbol); var requestType = CreateRequestTypeFromMethodParameters(methodParameters); var responseType = MagicOnionTypeInfo.KnownTypes.MessagePack_Nil; switch (methodReturnType.FullNameOpenType) @@ -129,11 +129,11 @@ static bool TryCreateHubMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceT diagnostic = null; return true; } - static bool TryCreateHubReceiverMethodInfoFromMethodSymbol(MagicOnionTypeInfo interfaceType, MagicOnionTypeInfo receiverType, IMethodSymbol methodSymbol, [NotNullWhen(true)] out MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo? methodInfo, out Diagnostic? diagnostic) + static bool TryCreateHubReceiverMethodInfoFromMethodSymbol(MethodCollectorContext ctx, MagicOnionTypeInfo interfaceType, MagicOnionTypeInfo receiverType, IMethodSymbol methodSymbol, [NotNullWhen(true)] out MagicOnionStreamingHubInfo.MagicOnionHubMethodInfo? methodInfo, out Diagnostic? diagnostic) { var hubId = GetHubMethodIdFromMethodSymbol(methodSymbol); - var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); - var methodParameters = CreateParameterInfoListFromMethodSymbol(methodSymbol); + var methodReturnType = ctx.GetOrCreateTypeInfoFromSymbol(methodSymbol.ReturnType); + var methodParameters = CreateParameterInfoListFromMethodSymbol(ctx, methodSymbol); var requestType = CreateRequestTypeFromMethodParameters(methodParameters); var responseType = MagicOnionTypeInfo.KnownTypes.MessagePack_Nil; if (methodReturnType != MagicOnionTypeInfo.KnownTypes.System_Void) @@ -164,7 +164,7 @@ static IReadOnlyList GetServices(MethodCollectorContext c { cancellationToken.ThrowIfCancellationRequested(); - var serviceType = MagicOnionTypeInfo.CreateFromSymbol(x); + var serviceType = ctx.GetOrCreateTypeInfoFromSymbol(x); var hasIgnore = HasIgnoreAttribute(x); if (hasIgnore) { @@ -176,7 +176,7 @@ static IReadOnlyList GetServices(MethodCollectorContext c foreach (var methodSymbol in x.GetMembers().OfType()) { if (HasIgnoreAttribute(methodSymbol)) continue; - if (TryCreateServiceMethodInfoFromMethodSymbol(serviceType, methodSymbol, out var methodInfo, out var diagnostic)) + if (TryCreateServiceMethodInfoFromMethodSymbol(ctx, serviceType, methodSymbol, out var methodInfo, out var diagnostic)) { methods.Add(methodInfo); } @@ -204,10 +204,10 @@ static IReadOnlyList GetServices(MethodCollectorContext c .ToArray(); } - static bool TryCreateServiceMethodInfoFromMethodSymbol(MagicOnionTypeInfo serviceType, IMethodSymbol methodSymbol, [NotNullWhen(true)] out MagicOnionServiceInfo.MagicOnionServiceMethodInfo? serviceMethodInfo, out Diagnostic? diagnostic) + static bool TryCreateServiceMethodInfoFromMethodSymbol(MethodCollectorContext ctx, MagicOnionTypeInfo serviceType, IMethodSymbol methodSymbol, [NotNullWhen(true)] out MagicOnionServiceInfo.MagicOnionServiceMethodInfo? serviceMethodInfo, out Diagnostic? diagnostic) { - var methodReturnType = MagicOnionTypeInfo.CreateFromSymbol(methodSymbol.ReturnType); - var methodParameters = CreateParameterInfoListFromMethodSymbol(methodSymbol); + var methodReturnType = ctx.GetOrCreateTypeInfoFromSymbol(methodSymbol.ReturnType); + var methodParameters = CreateParameterInfoListFromMethodSymbol(ctx, methodSymbol); var methodType = MethodType.Other; var requestType = CreateRequestTypeFromMethodParameters(methodParameters); var responseType = MagicOnionTypeInfo.KnownTypes.System_Void; @@ -288,8 +288,8 @@ static bool TryCreateServiceMethodInfoFromMethodSymbol(MagicOnionTypeInfo servic return true; } - static IReadOnlyList CreateParameterInfoListFromMethodSymbol(IMethodSymbol methodSymbol) - => methodSymbol.Parameters.Select(x => MagicOnionMethodParameterInfo.CreateFromSymbol(x)).ToArray(); + static IReadOnlyList CreateParameterInfoListFromMethodSymbol(MethodCollectorContext ctx, IMethodSymbol methodSymbol) + => methodSymbol.Parameters.Select(x => MagicOnionMethodParameterInfo.CreateFromTypeInfoAndSymbol(ctx.GetOrCreateTypeInfoFromSymbol(x.Type), x)).ToArray(); static MagicOnionTypeInfo CreateRequestTypeFromMethodParameters(IReadOnlyList parameters) => (parameters.Count == 0) @@ -304,6 +304,16 @@ record MethodCollectorContext public required IReadOnlyList ServiceInterfaces { get; init; } public required IReadOnlyList HubInterfaces { get; init; } public List ReportDiagnostics { get; } = new(); + public Dictionary TypeInfoCache { get; } = new (SymbolEqualityComparer.Default); + + public MagicOnionTypeInfo GetOrCreateTypeInfoFromSymbol(ITypeSymbol symbol) + { + if (TypeInfoCache.TryGetValue(symbol, out var typeInfo)) + { + return typeInfo; + } + return TypeInfoCache[symbol] = MagicOnionTypeInfo.CreateFromSymbol(symbol); + } public static MethodCollectorContext CreateFromInterfaceSymbols(ImmutableArray interfaceSymbols, ReferenceSymbols referenceSymbols, CancellationToken cancellationToken) { diff --git a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs index e01365e7b..7c31dd345 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeAnalysis/SerializationInfoCollector.cs @@ -17,51 +17,42 @@ public SerializationInfoCollector(ISerializationFormatterNameMapper serializatio public MagicOnionSerializationInfoCollection Collect(MagicOnionServiceCollection serviceCollection) => Collect(EnumerateTypes(serviceCollection)); - static IEnumerable EnumerateTypes(MagicOnionServiceCollection serviceCollection) + static IReadOnlyList EnumerateTypes(MagicOnionServiceCollection serviceCollection) { - return Enumerable.Concat( - serviceCollection.Services.SelectMany(service => + var types = new HashSet(); + + foreach (var service in serviceCollection.Services) + { + foreach (var method in service.Methods) { - return service.Methods.SelectMany(method => - { - return Enumerable.Concat( - EnumerateTypes(method.ResponseType), - EnumerateTypes(method.RequestType) - ); - }); - }), - serviceCollection.Hubs.SelectMany(hub => + EnumerateTypesCore(types, method.ResponseType); + EnumerateTypesCore(types, method.RequestType); + } + } + foreach (var hub in serviceCollection.Hubs) + { + foreach (var method in hub.Methods) { - return Enumerable.Concat( - hub.Receiver.Methods.SelectMany(method => - { - return Enumerable.Concat( - EnumerateTypes(method.ResponseType), - EnumerateTypes(method.RequestType) - ); - }), - hub.Methods.SelectMany(method => - { - return Enumerable.Concat( - EnumerateTypes(method.ResponseType), - EnumerateTypes(method.RequestType) - ); - }) - ); - }) - ); - } - static IEnumerable EnumerateTypes(MagicOnionTypeInfo type) - { - yield return type; + EnumerateTypesCore(types, method.ResponseType); + EnumerateTypesCore(types, method.RequestType); + } + foreach (var method in hub.Receiver.Methods) + { + EnumerateTypesCore(types, method.ResponseType); + EnumerateTypesCore(types, method.RequestType); + } + } + + return types.ToArray(); - if (type.HasGenericArguments) + static void EnumerateTypesCore(HashSet types, MagicOnionTypeInfo rootType) { - foreach (var genericTypeArg in type.GenericArguments) + types.Add(rootType); + if (rootType.HasGenericArguments) { - foreach (var t in EnumerateTypes(genericTypeArg)) + foreach (var genericTypeArg in rootType.GenericArguments) { - yield return t; + EnumerateTypesCore(types, genericTypeArg); } } } From 205aeeb80286ffda51bebb44e98faee3d2c537bf Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 24 Oct 2023 17:27:50 +0900 Subject: [PATCH 62/66] More reduce allocation during code generation --- .../CodeGen/MagicOnionInitializerGenerator.cs | 26 +++---- ...emoryPackFormatterRegistrationGenerator.cs | 37 +++++----- .../MessagePackEnumFormatterGenerator.cs | 16 +++-- .../MessagePackFormatterResolverGenerator.cs | 60 ++++++++-------- .../SerializationFormatterCodeGenContext.cs | 8 --- .../StaticMagicOnionClientGenerator.cs | 52 +++++++------- .../StaticStreamingHubClientGenerator.cs | 68 ++++++++++--------- .../GenerationContext.cs | 14 +++- .../Helpers/StringBuilderExtensions.cs | 36 ++++++++++ 9 files changed, 187 insertions(+), 130 deletions(-) create mode 100644 src/MagicOnion.Client.SourceGenerator/Helpers/StringBuilderExtensions.cs diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs index 100a5a2f2..79774d93a 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MagicOnionInitializerGenerator.cs @@ -6,8 +6,10 @@ internal class MagicOnionInitializerGenerator { public static string Build(GenerationContext generationContext, MagicOnionServiceCollection serviceCollection) { - var writer = new StringWriter(); - writer.WriteLine($$""" + using var pooledStringBuilder = generationContext.GetPooledStringBuilder(); + var writer = pooledStringBuilder.Instance; + + writer.AppendLine($$""" // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete @@ -15,13 +17,13 @@ public static string Build(GenerationContext generationContext, MagicOnionServic """); if (!string.IsNullOrEmpty(generationContext.Namespace)) { - writer.WriteLine($$""" + writer.AppendLineWithFormat($$""" namespace {{generationContext.Namespace}} { """); } - writer.WriteLine($$""" + writer.AppendLineWithFormat($$""" using global::System; using global::System.Collections.Generic; using global::System.Linq; @@ -48,7 +50,7 @@ partial class {{generationContext.InitializerPartialTypeName}} if (!generationContext.Options.DisableAutoRegistration) { - writer.WriteLine($$""" + writer.AppendLineWithFormat($$""" #if UNITY_2019_4_OR_NEWER [global::UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)] #elif NET5_0_OR_GREATER @@ -57,7 +59,7 @@ partial class {{generationContext.InitializerPartialTypeName}} internal static void Register() => TryRegisterProviderFactory(); """); } - writer.WriteLine($$""" + writer.AppendLineWithFormat($$""" /// /// Register the generated client factory providers if it's not registered yet. This method will register only once. @@ -100,15 +102,15 @@ static MagicOnionClientFactoryCache() foreach (var serviceInfo in serviceCollection.Services) { - writer.WriteLine($$""" + writer.AppendLineWithFormat($$""" if (typeof(T) == typeof({{serviceInfo.ServiceType.FullName}})) { factory = ((global::MagicOnion.Client.MagicOnionClientFactoryDelegate<{{serviceInfo.ServiceType.FullName}}>)((x, y) => new MagicOnionGeneratedClient.{{serviceInfo.GetClientFullName()}}(x, y))); } """); } - - writer.WriteLine($$""" + + writer.AppendLineWithFormat($$""" Factory = (global::MagicOnion.Client.MagicOnionClientFactoryDelegate)factory; } } @@ -124,7 +126,7 @@ static StreamingHubClientFactoryCache() """); foreach (var hubInfo in serviceCollection.Hubs) { - writer.WriteLine($$""" + writer.AppendLineWithFormat($$""" if (typeof(TStreamingHub) == typeof({{hubInfo.ServiceType.FullName}}) && typeof(TReceiver) == typeof({{hubInfo.Receiver.ReceiverType.FullName}})) { factory = ((global::MagicOnion.Client.StreamingHubClientFactoryDelegate<{{hubInfo.ServiceType.FullName}}, {{hubInfo.Receiver.ReceiverType.FullName}}>)((a, _, b, c, d, e) => new MagicOnionGeneratedClient.{{hubInfo.GetClientFullName()}}(a, b, c, d, e))); @@ -132,7 +134,7 @@ static StreamingHubClientFactoryCache() """); } - writer.WriteLine($$$""" + writer.AppendLineWithFormat($$$""" Factory = (global::MagicOnion.Client.StreamingHubClientFactoryDelegate)factory; } @@ -142,7 +144,7 @@ static StreamingHubClientFactoryCache() """); if (!string.IsNullOrEmpty(generationContext.Namespace)) { - writer.WriteLine($$""" + writer.AppendLineWithFormat($$""" } """); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPack/MemoryPackFormatterRegistrationGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPack/MemoryPackFormatterRegistrationGenerator.cs index f2b6e5e40..2431fe134 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPack/MemoryPackFormatterRegistrationGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MemoryPack/MemoryPackFormatterRegistrationGenerator.cs @@ -1,19 +1,24 @@ +using System.Text; + namespace MagicOnion.Client.SourceGenerator.CodeGen.MemoryPack; internal class MemoryPackFormatterRegistrationGenerator : ISerializerFormatterGenerator { public string Build(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { - EmitPreamble(generationContext, ctx); - EmitBody(generationContext, ctx); - EmitPostscript(generationContext, ctx); + using var pooledStringBuilder = generationContext.GetPooledStringBuilder(); + var writer = pooledStringBuilder.Instance; + + EmitPreamble(generationContext, ctx, writer); + EmitBody(generationContext, ctx, writer); + EmitPostscript(generationContext, ctx, writer); - return ctx.GetWrittenText(); + return writer.ToString(); } - static void EmitPreamble(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) + static void EmitPreamble(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx, StringBuilder writer) { - ctx.TextWriter.WriteLine(""" + writer.AppendLine(""" // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete @@ -22,33 +27,33 @@ static void EmitPreamble(GenerationContext generationContext, SerializationForma """); } - static void EmitBody(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) + static void EmitBody(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx, StringBuilder writer) { if (!string.IsNullOrEmpty(generationContext.Namespace)) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" namespace {{generationContext.Namespace}} { """); } - ctx.TextWriter.WriteLine($$""" + writer.AppendLine($$""" using global::System; using global::MemoryPack; """); - EmitRegister(generationContext, ctx); + EmitRegister(generationContext, ctx, writer); if (!string.IsNullOrEmpty(generationContext.Namespace)) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLine($$""" } """); } } - static void EmitRegister(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) + static void EmitRegister(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx, StringBuilder writer) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" partial class {{generationContext.InitializerPartialTypeName}} { /// @@ -59,17 +64,17 @@ public static void RegisterMemoryPackFormatters() """); foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" global::MemoryPack.MemoryPackFormatterProvider.Register(new {{(resolverInfo.FormatterName.StartsWith("global::") || string.IsNullOrWhiteSpace(ctx.FormatterNamespace) ? "" : ctx.FormatterNamespace + ".") + resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}); """); } - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" } } """); } - static void EmitPostscript(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) + static void EmitPostscript(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx, StringBuilder writer) { } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackEnumFormatterGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackEnumFormatterGenerator.cs index 909cfc8f3..c2b0315e4 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackEnumFormatterGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackEnumFormatterGenerator.cs @@ -6,8 +6,10 @@ internal class MessagePackEnumFormatterGenerator { public static string Build(GenerationContext context, IEnumerable enumSerializationInfoSet) { - var writer = new StringWriter(); - writer.WriteLine($$""" + using var pooledStringBuilder = context.GetPooledStringBuilder(); + var writer = pooledStringBuilder.Instance; + + writer.AppendLineWithFormat($$""" // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete @@ -17,13 +19,13 @@ public static string Build(GenerationContext context, IEnumerable { public void Serialize(ref global::MessagePack.MessagePackWriter writer, {{info.FullName}} value, global::MessagePack.MessagePackSerializerOptions options) @@ -51,14 +53,14 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, {{info.F """); } - writer.WriteLine($$""" + writer.AppendLineWithFormat($$""" } } """); if (!string.IsNullOrEmpty(context.Namespace)) { - writer.WriteLine($$""" + writer.AppendLineWithFormat($$""" } """); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackFormatterResolverGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackFormatterResolverGenerator.cs index d9188e709..aeff988f9 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackFormatterResolverGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/MessagePack/MessagePackFormatterResolverGenerator.cs @@ -1,3 +1,4 @@ +using System.Text; using MagicOnion.Client.SourceGenerator.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator.CodeGen.MessagePack; @@ -6,16 +7,19 @@ internal class MessagePackFormatterResolverGenerator : ISerializerFormatterGener { public string Build(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) { - EmitPreamble(generationContext, ctx); - EmitBody(generationContext, ctx); - EmitPostscript(generationContext, ctx); + using var pooledStringBuilder = generationContext.GetPooledStringBuilder(); + var writer = pooledStringBuilder.Instance; - return ctx.GetWrittenText(); + EmitPreamble(generationContext, ctx, writer); + EmitBody(generationContext, ctx, writer); + EmitPostscript(generationContext, ctx, writer); + + return writer.ToString(); } - static void EmitPreamble(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) + static void EmitPreamble(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx, StringBuilder writer) { - ctx.TextWriter.WriteLine(""" + writer.AppendLine(""" // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete @@ -25,16 +29,16 @@ static void EmitPreamble(GenerationContext generationContext, SerializationForma """); } - static void EmitBody(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) + static void EmitBody(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx, StringBuilder writer) { if (!string.IsNullOrEmpty(generationContext.Namespace)) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" namespace {{generationContext.Namespace}} { """); } - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" using global::System; using global::MessagePack; @@ -46,25 +50,25 @@ partial class {{generationContext.InitializerPartialTypeName}} public static global::MessagePack.IFormatterResolver Resolver => MessagePackGeneratedResolver.Instance; """); - EmitResolver(ctx); - EmitGetFormatterHelper(ctx); - EmitTypeHints(ctx); + EmitResolver(ctx, writer); + EmitGetFormatterHelper(ctx, writer); + EmitTypeHints(ctx, writer); - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" } """); if (!string.IsNullOrEmpty(generationContext.Namespace)) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" } """); } } - static void EmitResolver(SerializationFormatterCodeGenContext ctx) + static void EmitResolver(SerializationFormatterCodeGenContext ctx, StringBuilder writer) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" class MessagePackGeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new MessagePackGeneratedResolver(); @@ -91,9 +95,9 @@ static FormatterCache() """); } - static void EmitGetFormatterHelper(SerializationFormatterCodeGenContext ctx) + static void EmitGetFormatterHelper(SerializationFormatterCodeGenContext ctx, StringBuilder writer) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" static class MessagePackGeneratedGetFormatterHelper { static readonly global::System.Collections.Generic.Dictionary lookup; @@ -105,11 +109,11 @@ static MessagePackGeneratedGetFormatterHelper() """); foreach (var (resolverInfo, index) in ctx.FormatterRegistrations.Select((x, i) => (x, i))) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" {typeof({{resolverInfo.FullName}}), {{index}}}, """); } - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" }; } internal static object GetFormatter(global::System.Type t) @@ -128,19 +132,19 @@ internal static object GetFormatter(global::System.Type t) if (resolverInfo is EnumSerializationInfo) { // Use EnumFormatter generated by MagicOnion.Client.SourceGenerator - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" case {{index}}: return new MessagePackEnumFormatters.{{resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}; """); } else { // Use formatter generated by MessagePack generator. - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" case {{index}}: return new {{(resolverInfo.FormatterName.StartsWith("global::") || string.IsNullOrWhiteSpace(ctx.FormatterNamespace) ? "" : ctx.FormatterNamespace + ".") + resolverInfo.FormatterName}}{{resolverInfo.FormatterConstructorArgs}}; """); } } - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" default: return null; } } @@ -148,9 +152,9 @@ internal static object GetFormatter(global::System.Type t) """); } - static void EmitTypeHints(SerializationFormatterCodeGenContext ctx) + static void EmitTypeHints(SerializationFormatterCodeGenContext ctx, StringBuilder writer) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" /// Type hints for Ahead-of-Time compilation. [Preserve] static class TypeHints @@ -161,17 +165,17 @@ internal static void Register() """); foreach (var typeHint in ctx.TypeHints) { - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" _ = MessagePackGeneratedResolver.Instance.GetFormatter<{{typeHint.FullName}}>(); """); } - ctx.TextWriter.WriteLine($$""" + writer.AppendLineWithFormat($$""" } } """); } - static void EmitPostscript(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx) + static void EmitPostscript(GenerationContext generationContext, SerializationFormatterCodeGenContext ctx, StringBuilder writer) { } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs index ea25b4058..a28eaedec 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/SerializationFormatterCodeGenContext.cs @@ -5,22 +5,14 @@ namespace MagicOnion.Client.SourceGenerator.CodeGen; public class SerializationFormatterCodeGenContext { - readonly StringWriter underlyingWriter; - public string FormatterNamespace { get; } public IReadOnlyList FormatterRegistrations { get; } public IReadOnlyList TypeHints { get; } - public TextWriter TextWriter => underlyingWriter; - public SerializationFormatterCodeGenContext(string formatterNamespace, IReadOnlyList formatterRegistrations, IReadOnlyList typeHints) { FormatterNamespace = formatterNamespace; FormatterRegistrations = formatterRegistrations; TypeHints = typeHints; - - underlyingWriter = new StringWriter(); } - - public string GetWrittenText() => underlyingWriter.ToString(); } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs index aa841fb57..61eb37ded 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticMagicOnionClientGenerator.cs @@ -1,3 +1,4 @@ +using System.Text; using MagicOnion.Client.SourceGenerator.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator.CodeGen; @@ -6,35 +7,36 @@ public class StaticMagicOnionClientGenerator { class ServiceClientBuildContext { - public ServiceClientBuildContext(MagicOnionServiceInfo service, TextWriter textWriter) + public ServiceClientBuildContext(MagicOnionServiceInfo service, StringBuilder writer) { Service = service; - TextWriter = textWriter; + Writer = writer; } public MagicOnionServiceInfo Service { get; } - public TextWriter TextWriter { get; } + public StringBuilder Writer { get; } } public static string Build(GenerationContext generationContext, MagicOnionServiceInfo serviceInfo) { - var textWriter = new StringWriter(); + using var pooledStringBuilder = generationContext.GetPooledStringBuilder(); + var writer = pooledStringBuilder.Instance; - EmitHeader(generationContext, textWriter); + EmitHeader(generationContext, writer); - var buildContext = new ServiceClientBuildContext(serviceInfo, textWriter); + var buildContext = new ServiceClientBuildContext(serviceInfo, writer); EmitPreamble(generationContext, buildContext); EmitServiceClientClass(generationContext, buildContext); EmitPostscript(generationContext, buildContext); - return textWriter.ToString(); + return writer.ToString(); } - static void EmitHeader(GenerationContext generationContext, TextWriter textWriter) + static void EmitHeader(GenerationContext generationContext, StringBuilder writer) { - textWriter.WriteLine(""" + writer.AppendLine(""" // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete @@ -47,12 +49,12 @@ static void EmitPreamble(GenerationContext generationContext, ServiceClientBuild { if (!string.IsNullOrWhiteSpace(generationContext.Namespace)) { - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" namespace {{generationContext.Namespace}} { """); } - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" using global::System; using global::Grpc.Core; using global::MagicOnion; @@ -68,14 +70,14 @@ static partial class MagicOnionGeneratedClient static void EmitPostscript(GenerationContext generationContext, ServiceClientBuildContext ctx) { - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" } } """); if (!string.IsNullOrWhiteSpace(generationContext.Namespace)) { - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" } """); } @@ -87,7 +89,7 @@ static void EmitServiceClientClass(GenerationContext generationContext, ServiceC // public class {ServiceName}Client : MagicOnionClientBase<{ServiceName}>, {ServiceName} // { // - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" [global::MagicOnion.Ignore] public class {{ctx.Service.GetClientFullName()}} : global::MagicOnion.Client.MagicOnionClientBase<{{ctx.Service.ServiceType.FullName}}>, {{ctx.Service.ServiceType.FullName}} { @@ -104,7 +106,7 @@ public class {{ctx.Service.GetClientFullName()}} : global::MagicOnion.Client.Mag // public {MethodType}Result MethodName(TArg1 arg1, TArg2 arg2, ...) => this.core.MethodName.Invoke{MethodType}(this, "ServiceName/MethodName", new DynamicArgumentTuple(arg1, arg2, ...)); ... EmitServiceMethods(ctx); - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" } """); // } @@ -112,16 +114,16 @@ public class {{ctx.Service.GetClientFullName()}} : global::MagicOnion.Client.Mag static void EmitClone(ServiceClientBuildContext ctx) { - ctx.TextWriter.WriteLine($""" + ctx.Writer.AppendLineWithFormat($""" protected override global::MagicOnion.Client.MagicOnionClientBase<{ctx.Service.ServiceType.FullName}> Clone(global::MagicOnion.Client.MagicOnionClientOptions options) => new {ctx.Service.GetClientFullName()}(options, core); """); - ctx.TextWriter.WriteLine(); + ctx.Writer.AppendLine(); } static void EmitConstructor(ServiceClientBuildContext ctx) { - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" public {{ctx.Service.GetClientFullName()}}(global::MagicOnion.Client.MagicOnionClientOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) : base(options) { this.core = new ClientCore(serializerProvider); @@ -138,7 +140,7 @@ static void EmitConstructor(ServiceClientBuildContext ctx) static void EmitFields(ServiceClientBuildContext ctx) { // private readonly ClientCore core; - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" readonly ClientCore core; """); @@ -176,7 +178,7 @@ _ when (method.MethodType != MethodType.Unary && method.MethodType != MethodType }; var hasNonGenericUnaryResult = method.MethodReturnType == MagicOnionTypeInfo.KnownTypes.MagicOnion_UnaryResult; - ctx.TextWriter.WriteLine($""" + ctx.Writer.AppendLineWithFormat($""" public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) => this.core.{method.MethodName}.Invoke{method.MethodType}{(hasNonGenericUnaryResult ? "NonGeneric" : "")}(this, "{method.Path}"{invokeRequestParameters}); """); @@ -199,7 +201,7 @@ static void EmitClientCore(ServiceClientBuildContext ctx) */ // class ClientCore { - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" class ClientCore { """); @@ -207,13 +209,13 @@ class ClientCore // public RawMethodInvoker MethodName; foreach (var method in ctx.Service.Methods) { - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" public global::MagicOnion.Client.Internal.RawMethodInvoker<{{method.RequestType.FullName}}, {{method.ResponseType.FullName}}> {{method.MethodName}}; """); } // public ClientCore(IMagicOnionSerializerProvider serializerProvider) { - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider) { """); @@ -222,11 +224,11 @@ public ClientCore(global::MagicOnion.Serialization.IMagicOnionSerializerProvider foreach (var method in ctx.Service.Methods) { var createMethodVariant = $"{(method.RequestType.IsValueType ? "Value" : "Ref")}Type_{(method.ResponseType.IsValueType ? "Value" : "Ref")}Type"; - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" this.{{method.MethodName}} = global::MagicOnion.Client.Internal.RawMethodInvoker.Create_{{createMethodVariant}}<{{method.RequestType.FullName}}, {{method.ResponseType.FullName}}>(global::Grpc.Core.MethodType.{{method.MethodType}}, "{{method.ServiceName}}", "{{method.MethodName}}", serializerProvider); """); } - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" } } diff --git a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs index 444b42a6d..3927b64c8 100644 --- a/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs +++ b/src/MagicOnion.Client.SourceGenerator/CodeGen/StaticStreamingHubClientGenerator.cs @@ -1,3 +1,4 @@ +using System.Text; using MagicOnion.Client.SourceGenerator.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator.CodeGen; @@ -6,35 +7,36 @@ public class StaticStreamingHubClientGenerator { class StreamingHubClientBuildContext { - public StreamingHubClientBuildContext(MagicOnionStreamingHubInfo hub, TextWriter textWriter) + public StreamingHubClientBuildContext(MagicOnionStreamingHubInfo hub, StringBuilder writer) { Hub = hub; - TextWriter = textWriter; + Writer = writer; } public MagicOnionStreamingHubInfo Hub { get; } - public TextWriter TextWriter { get; } + public StringBuilder Writer { get; } } public static string Build(GenerationContext generationContext, MagicOnionStreamingHubInfo hubInfo) { - var textWriter = new StringWriter(); + using var pooledStringBuilder = generationContext.GetPooledStringBuilder(); + var writer = pooledStringBuilder.Instance; - EmitHeader(generationContext, textWriter); + EmitHeader(generationContext, writer); - var buildContext = new StreamingHubClientBuildContext(hubInfo, textWriter); + var buildContext = new StreamingHubClientBuildContext(hubInfo, writer); EmitPreamble(generationContext, buildContext); EmitHubClientClass(generationContext, buildContext); EmitPostscript(generationContext, buildContext); - return textWriter.ToString(); + return writer.ToString(); } - static void EmitHeader(GenerationContext generationContext, TextWriter textWriter) + static void EmitHeader(GenerationContext generationContext, StringBuilder writer) { - textWriter.WriteLine(""" + writer.AppendLine(""" // #pragma warning disable CS0618 // 'member' is obsolete: 'text' #pragma warning disable CS0612 // 'member' is obsolete @@ -49,12 +51,12 @@ static void EmitPreamble(GenerationContext generationContext, StreamingHubClient { if (!string.IsNullOrWhiteSpace(generationContext.Namespace)) { - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" namespace {{generationContext.Namespace}} { """); } - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" using global::System; using global::Grpc.Core; using global::MagicOnion; @@ -70,14 +72,14 @@ static partial class MagicOnionGeneratedClient static void EmitPostscript(GenerationContext generationContext, StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" } } """); if (!string.IsNullOrWhiteSpace(generationContext.Namespace)) { - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" } """); } @@ -85,7 +87,7 @@ static void EmitPostscript(GenerationContext generationContext, StreamingHubClie static void EmitHubClientClass(GenerationContext generationContext, StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" [global::MagicOnion.Ignore] public class {{ctx.Hub.GetClientFullName()}} : global::MagicOnion.Client.StreamingHubClientBase<{{ctx.Hub.ServiceType.FullName}}, {{ctx.Hub.Receiver.ReceiverType.FullName}}>, {{ctx.Hub.ServiceType.FullName}} { @@ -96,7 +98,7 @@ public class {{ctx.Hub.GetClientFullName()}} : global::MagicOnion.Client.Streami EmitFireAndForget(ctx); EmitOnBroadcastEvent(ctx); EmitOnResponseEvent(ctx); - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" } """); // } @@ -104,7 +106,7 @@ public class {{ctx.Hub.GetClientFullName()}} : global::MagicOnion.Client.Streami static void EmitProperties(StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" protected override global::Grpc.Core.Method DuplexStreamingAsyncMethod { get; } """); @@ -112,7 +114,7 @@ static void EmitProperties(StreamingHubClientBuildContext ctx) static void EmitConstructor(StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" public {{ctx.Hub.GetClientFullName()}}(global::Grpc.Core.CallInvoker callInvoker, global::System.String host, global::Grpc.Core.CallOptions options, global::MagicOnion.Serialization.IMagicOnionSerializerProvider serializerProvider, global::MagicOnion.Client.IMagicOnionClientLogger logger) : base(callInvoker, host, options, serializerProvider, logger) { @@ -120,12 +122,12 @@ static void EmitConstructor(StreamingHubClientBuildContext ctx) DuplexStreamingAsyncMethod = new global::Grpc.Core.Method(global::Grpc.Core.MethodType.DuplexStreaming, "{{ctx.Hub.ServiceType.Name}}", "Connect", marshaller, marshaller); } """); - ctx.TextWriter.WriteLine(); + ctx.Writer.AppendLine(); } static void EmitFireAndForget(StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" public {{ctx.Hub.ServiceType.FullName}} FireAndForget() => new FireAndForgetClient(this); @@ -143,7 +145,7 @@ public FireAndForgetClient({{ctx.Hub.GetClientFullName()}} parent) """); EmitHubMethods(ctx, isFireAndForget: true); - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" } """); @@ -171,41 +173,41 @@ static void EmitHubMethods(StreamingHubClientBuildContext ctx, bool isFireAndFor _ => $", {method.Parameters.ToNewDynamicArgumentTuple()}", }; - if (isFireAndForget) ctx.TextWriter.Write(" "); - ctx.TextWriter.WriteLine($""" + if (isFireAndForget) ctx.Writer.Append(" "); + ctx.Writer.AppendLineWithFormat($""" public {method.MethodReturnType.FullName} {method.MethodName}({method.Parameters.ToMethodSignaturize()}) """); - if (isFireAndForget) ctx.TextWriter.Write(" "); + if (isFireAndForget) ctx.Writer.Append(" "); if (method.MethodReturnType == MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_ValueTask) { // ValueTask - ctx.TextWriter.WriteLine($""" + ctx.Writer.AppendLineWithFormat($""" => new global::System.Threading.Tasks.ValueTask({(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters})); """); } else if (method.MethodReturnType.HasGenericArguments && method.MethodReturnType.GetGenericTypeDefinition() == MagicOnionTypeInfo.KnownTypes.System_Threading_Tasks_ValueTask) { // ValueTask - ctx.TextWriter.WriteLine($""" + ctx.Writer.AppendLineWithFormat($""" => new global::System.Threading.Tasks.ValueTask<{method.ResponseType.FullName}>({(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters})); """); } else { // Task, Task - ctx.TextWriter.WriteLine($""" + ctx.Writer.AppendLineWithFormat($""" => {(isFireAndForget ? "parent.WriteMessageFireAndForgetAsync" : "base.WriteMessageWithResponseAsync")}<{method.RequestType.FullName}, {method.ResponseType.FullName}>({method.HubId}{writeMessageParameters}); """); } } - ctx.TextWriter.WriteLine(); + ctx.Writer.AppendLine(); } static void EmitOnBroadcastEvent(StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" protected override void OnBroadcastEvent(global::System.Int32 methodId, global::System.ArraySegment data) { switch (methodId) @@ -220,7 +222,7 @@ protected override void OnBroadcastEvent(global::System.Int32 methodId, global:: _ => string.Join(", ", Enumerable.Range(1, method.Parameters.Count).Select(x => $"value.Item{x}")) }; - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" case {{method.HubId}}: // {{method.MethodReturnType.ToDisplayName()}} {{method.MethodName}}({{method.Parameters.ToMethodSignaturize()}}) { var value = base.Deserialize<{{method.RequestType.FullName}}>(data); @@ -229,7 +231,7 @@ protected override void OnBroadcastEvent(global::System.Int32 methodId, global:: break; """); } - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" } } @@ -238,7 +240,7 @@ protected override void OnBroadcastEvent(global::System.Int32 methodId, global:: static void EmitOnResponseEvent(StreamingHubClientBuildContext ctx) { - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" protected override void OnResponseEvent(global::System.Int32 methodId, global::System.Object taskCompletionSource, global::System.ArraySegment data) { switch (methodId) @@ -246,13 +248,13 @@ protected override void OnResponseEvent(global::System.Int32 methodId, global::S """); foreach (var method in ctx.Hub.Methods) { - ctx.TextWriter.WriteLine($$""" + ctx.Writer.AppendLineWithFormat($$""" case {{method.HubId}}: // {{method.MethodReturnType.ToDisplayName()}} {{method.MethodName}}({{method.Parameters.ToMethodSignaturize()}}) base.SetResultForResponse<{{method.ResponseType.FullName}}>(taskCompletionSource, data); break; """); } - ctx.TextWriter.WriteLine(""" + ctx.Writer.AppendLine(""" } } diff --git a/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs b/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs index 5f9e2f216..f71a5ff0e 100644 --- a/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs +++ b/src/MagicOnion.Client.SourceGenerator/GenerationContext.cs @@ -1,3 +1,4 @@ +using System.Text; using Microsoft.CodeAnalysis; namespace MagicOnion.Client.SourceGenerator; @@ -7,7 +8,18 @@ public readonly record struct GenerationContext( string InitializerPartialTypeName, SourceProductionContext SourceProductionContext, GenerationOptions Options -); +) +{ + readonly StringBuilder pooledStringBuilder = new(); + + public PooledStringBuilder GetPooledStringBuilder() + => new PooledStringBuilder(pooledStringBuilder); + + public record struct PooledStringBuilder(StringBuilder Instance) : IDisposable + { + public void Dispose() => Instance.Clear(); + } +} // This enum must be mirror of generated `SerializerType` (MagicOnionClientSourceGenerator.Emit) diff --git a/src/MagicOnion.Client.SourceGenerator/Helpers/StringBuilderExtensions.cs b/src/MagicOnion.Client.SourceGenerator/Helpers/StringBuilderExtensions.cs new file mode 100644 index 000000000..a630dfe61 --- /dev/null +++ b/src/MagicOnion.Client.SourceGenerator/Helpers/StringBuilderExtensions.cs @@ -0,0 +1,36 @@ +using System.Runtime.CompilerServices; +using System.Text; + +// ReSharper disable once CheckNamespace +namespace MagicOnion.Client.SourceGenerator; + +static class StringBuilderExtensions +{ + // NOTE: .NET Standard 2.0 doesn't have AppendInterpolatedStringHandler + public static StringBuilder AppendLineWithFormat(this StringBuilder sb, [InterpolatedStringHandlerArgument(nameof(sb))] StringBuilderInterpolatedStringHandler s) + { + sb.AppendLine(); + return sb; + } + + [InterpolatedStringHandler] + public readonly ref struct StringBuilderInterpolatedStringHandler + { + readonly StringBuilder sb; + + public StringBuilderInterpolatedStringHandler(int literalLength, int formattedCount, StringBuilder sb) + { + this.sb = sb; + } + + public void AppendLiteral(string s) + { + sb.Append(s); + } + + public void AppendFormatted(T t) + { + sb.Append(t); + } + } +} From ee6fce8018195787ea04380aa2e4407d429d980a Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 24 Oct 2023 17:48:07 +0900 Subject: [PATCH 63/66] Update MagicOnion.Client.SourceGenerator.Unity.dll --- .github/workflows/build-release.yml | 31 +++++++++++++++++- ...agicOnion.Client.SourceGenerator.Unity.dll | Bin 139776 -> 139264 bytes 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 9dc174323..c0ed8b005 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -72,6 +72,35 @@ jobs: branch: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }} tags: false + update-sourcegenerator-unity: + name: Update MagicOnion.Client.SourceGenerator.Unity + needs: [update-packagejson] + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - run: echo ${{ needs.update-packagejson.outputs.sha }} + - uses: actions/checkout@v3 + with: + ref: ${{ needs.update-packagejson.outputs.sha }} + - uses: ./.github/actions/setup-dotnet + - name: Publish MagicOnion.Client.SourceGenerator.Unity + run: dotnet publish -c ${{ env.BUILD_CONFIG }} -c Release ./src/MagicOnion.Client.SourceGenerator.Unity -o ./src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity + - name: Remove .deps.json and .pdbs + run: | + rm -f ./src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/*.deps.json + rm -f ./src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/*.pdb + - name: Commit files + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -m "feat: Update MagicOnion.Client.SourceGenerator.Unity" -a + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} + tags: true + build-dotnet: needs: [update-packagejson] runs-on: ubuntu-latest @@ -146,7 +175,7 @@ jobs: create-release: if: github.event.inputs.dry_run == 'false' needs: - [update-packagejson, build-dotnet, build-dotnet-experimental, build-unity] + [update-packagejson, update-sourcegenerator-unity, build-dotnet, build-dotnet-experimental, build-unity] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/MagicOnion.Client.SourceGenerator.Unity.dll index 0bc320e35978b2be4d9794e158a4561d8ef7593b..15c37adacc6571cffa013d6e5236c3df867c5235 100644 GIT binary patch literal 139264 zcmd44d3+Q_`UhOqJ=1gKAd_Pz7bF1!O=c1Z1V{o%U=cwPhzA0z2r42T4EBIm2!dQ5 zxQZfPc;SgB2zZ|>iudAuHtJx@LLRMk^w zS9cDadZ93d5I+3hy<3R;;M1>#-CuVWft*|MK(5#vdZFq*Iqrq3LynuBs+{X2XE`%Y zsyuqeoH@yPl}F92bmq^goIR&<)P#d8Pf8v$vo0qm+*6C5xUUf7q$$QcbNZ`pZXby5 zm07Z%5K%*jpo*O{5aCLMTi^?k$6*9XZ~D2uScFJs5h&O6WyDJVGQNfsgqLGh-?Il8w_!X8~1zs%Czdt9RwcZNmn;-=4tbQ=M_O&(73ExZX4n-%gljtc(^R|>JO6MYWOdYB+m0-JHO)HS>eDXCL^e2zE8qQh&qFf=($^r&ZJ64#P7P7|Fmxr81i0NaO{PXd_)es;#ok ze96r;B^(dxpw>Gl-%RtEiYFU9DwrKK2l}kwAiq5X<*|a+lvFR$%k4&)ZW7Rq>H4T0 zUk#Z)2QqwUK5lgOGtnp+N4q{st&(#f(@Rl4>ZR-2VRPPo$Pl)q{k?Z~SLD#C=bW)!3nJ{=gs7&s5tVP4_F-UBtjRi%a~f|Xf@${!sBY^A zx4_p{Po6*GkNEP#yNb~BWF&0&N925DB@3*Gl{h(KCDDh&3s3H-_axH00fg#BM6oe7 z#0vtEK&`Q3Y9wH{BKv}1kVHoU`5}8EFi68Aq2x%Ugf|LaFcM511q$G3z<@mrE|eSu zxy=)H@7}#5H{aY9g&~$DQTO3@YlO^0C5TbtzMlllo!Y=BrlK;?^&*l}!q#X_su?J}SH2-SsXdeeR(xQ-We=lZAU|MZB-V8Tl@q0rU~)K- zLXl7+2g;Ev+RBAs^s}~W)#@HUO{T(6$$+1Y3+#gPDt^$S01AyYP zFguVOhfq$gFBr0HjHK~Y3$kgA!60dT{Sozz5iMdbfQDfsIUdZ}`G!3Kepcg4pu!5# z(qS4_VF9Q{)CV;{fiL1qz!qY4{#b!OZbr%Kny;Z0rhO1Gz;ql8cXO#0!?oRj&>$K$ z070Ba`^S&Bl1rgMwKo@Pp&L&?MI}!s<>I4%iDw$|oXR}ie}QKnjY`Qj;z5DX-NMa1 zV2oJ281|t+)IVungsK8VdBjLgLM-NE>UH68yb)9JWQ4MV+>dfXiTqG<3L?4=2$`WI z+BY0849-Wlm0U5wh|g5kBkVtdSoo;qSSdEb|;YVwX`H(MbgC_e}8>$kT%3~|6p|Lt_n8}mV zc^je!q+wZzHb=J$V=ZJO^Ki7EQCO3XirVuy1=&b9@aHi9eB#F-SXg5vPeIrsD-0)3 zBi3F9nQge2!8-Rx8Vqic)ES5i$BV3}LDm>fqTiw0wZqL5MxnhBf!dFpAJHh5eI@|+ z(`Zv985l{!zC;Z*BG%_ zRR1a}Q;Q*w$Bmks(2khEXz_~teTKh1PF}9BJwblzEO55hB1lF}jJz`903s*}M{ocU zl$awpfC!Sp5gh1mw2`dT5ol^8;eOZxAJamFvkF^I6;w|yLAJdtXWw+#u*jsWM98YB zr11mPigq1H_5?=V8v-pSBKT)I2c}b+2K5&!xr`E-&MYqh-6c)9*-Jo&pyl+gC@jWc z`AQ|z`OwRTzM|8|YU(g=CxN5bm-Ol)OdBTVuA`wk|Lo;ZLe*muojqLH=g>oMoT_7~ z4mozRjy{{2sV0->Am~P)%h6Py$@4tXD><5~H+eoq*Gx0#qr)1B9K*bk0!ks;Qt*5L zlkKdN$t|4x6Ot#6^k`*rL#z1x?2K9_w|DXa;_qu`^fI~GlNVBa%+4rga_c8oAs$`b1f%K1u)?`vl=HMu2|YbidaEt7IJxk1@7 zxrp726#BVUbEmQoL&;P2qhu%}Qt8-|YL3;7atMryYW*PCAysQ@&HmA-^B`(Fg>l7N z#HKRZz6v@R$*bYo=#>_aJLq1b0PP(O8;Q!wC$B1B9FAti^NheMYewb8IQy9z4#XyB z1&lw3Q>Cw*aY?*C(s0lWffM1M6m<3sN|WUpkF|s+wreVZ@Zi? zAY)y1Ov{4iURft*WDzAJYh87*GuEV(B|0Sr0&mKbGAW7TOgx+vJ~- zdcxLEQg(4E5|L7l$v z*fpwSzJEc!wE<@)nBqk`F~#xZ%E=5Gg)9zoq%(_Dx*4Kt%CHBCn?e+#{kjMnMWXI$ zPeV0i1)LLz?-uZ3NVktB8S4RRn*-Uwikw(5h24vV1+x?ML%}}+Rz zWpQpt7Bl%2iM$o%D)2R8ZWR$<@-{+#O8q4wN-`O|U6n2YNf$)p=(ua)z%`cW2NXye~aA%j9ks_c*icI>-pO8UD#07P(sgQ`wcp;sC_tg|FqUI?j z#5up8tFoIZ>lo2wYIt2DD$m2ZJRS`&(~FXHA?|`WWzf=0CQ&et!AfUPeJ5(?aY8z4 zf1Bk7m&L6P8arN=)~I|OQN`)9eBkDT zBY7^%p4zVHpDvJM=}_D;13Ff^%1P}B=^2Ng_jF_*9vxml_sHmQyeq=hp+g2&{3`YD z13PAq?K&6L$sX*j3!3LPAk!G@L2Z_N2KAP_3$_|=JPQ;nxdGvV{R#zP#8AvV$CGolPi|cmslw0774|k41UI+~0HHDH8P2LR=$wwfVCti@%Vnvbd z^D=~p52shl$&9Wb=bxZpML@lWjxj4HbcwUI!rirJn5jX9z); zd5{~2Ggn?4=z%@83v(WJ{x}0hYvJH@M7bJMBQV_6XsH|VKa4Q_s9lF+jKyrJ?aLVo zxvCRrgZ4D^VkFTGt!fwxnL|AD`wgy6`DP%w0tN8YuF0*dC$d2D?9SAEo7}=9ZKe`U z=KzeJzyQt&NAp*7|2hRAN98T{DYy5Pana<=6sWVn) zI+t~zpqHi>OxJdxcon?WrF5+ACp%e{uI;zM?T(luu*adfyF310jQ?Bk-?cM}{}BI2 zq6K;Yxbg1X?asj^Y92fR#Y?ZFF$Z4m)Z+<$0B?O&aP zQ^@iEG6%cq|4(x;3Hg;dn8}^y;LlLkG-sH}v<4WkL}_~7>M#f6X?4drI5gZfNX*bg z?Yyv+p3dyD>}_S*X|CS8s6FRuZ0j&HWAkR2QTrAK*lr;T3s1PWlFKD?JX1DiF0P6c zly_~C=FiL=p010>VS>Lff9_Eit6S1_fn(luUC?$_^+}k(rmUj>zPa>F3h<+|7li`MtAD->;Ld9aaKQ{VH{zF`d%x+2-H4EN(et z+&H@4M<0->cbZqOrFA;bE3EAEsIcT_bp3GSv7lHjN>jipJgpFFPE*$U0 zYl573gI*F4Q|Bc?PCV+NW>y3_p=>jO*^G^04k@(+IpLh0BIxN;MQKUIua*ROO66G+ zU>G@{w8_-E6g8<>CT1*i9M4!|;khbh<`Jm$r_LqG>?1+Fpfi<@b+q(A@?6pgV{|;< z((4V&xr8#JIn6CmBkm;$U1Kk!L7P5?_8PxJy(3dDw7s`n?gEQDHjn!kkv!GA@n{a=U+dj@y!6kBk8w&Sh`BlO7VgI}&sbpJ105FP_);A% z;?x{RoTng<)V&~7FCq$E0#Zku=<%6e!&7ZnuYpw~lf9X?Gs8=uo*zxVM~2JG@&DId z|0J)}J$hl?M2|ARFrK9Q+!~kJ?Q^<4ui9fZ#!b_s)oq#@7^&N?y%9bhZGv;B4(*x^ zT*l)wCq6x$SkEq=0UIZ(Zj-8t#yQwEi1VC-WhxoV_ssZVdMX)&&XsI>##fLt^^(Q5Gaj}$oxgi*g0bWOeEf@(C-3p^d2UhnIQ~r>+EEEJc|WqpDeXs)fQ`fh zg!q(pDoWw8t>1adX>~sSi|{jQcTe;fs{A|r--14u z4WE9fbiPiVhX7q6?tGqErtdIxC7Y8SpDmcUJA|_ri+r5Bu#eFf6KGGgYIbL3aN?Rd zi|kXc&mw)!d8jjYsm%Kz9G-MIi)4cx;`@KU1>&T9W}Z2L%$RKF6UfUB*Dc|m+WBm( z3{g58r$OXl+ikJPvS@ngJbPNlL>)R?C3D9z-04$lorOAMtJdW<)zTa@U?#=5kqdXtQo;89xM@3b!I_tv2U*`)qmwXvYc1`y? z>GYYMRxaXmb*gtGb-e_+_tdW05e_D-pgKxYC7pnhW@=|}r*yh3XLT&g8JV&W#Z#8X z5{UB_r@*huV@3S)_eC#B97P2iQIaXxnT%7b+$;TlfJKhpZ{uzNBs?7spnfCg6PP%DAN#vN`H!n$cl%{R&zCCQN zqBx_%`JEEgs5!fz7`H$b!+Tlpx5iMcCVA|GEuyJ`2u9*?aMj6pg_g`oD13hdE`R4Uuk zg+d+rcX|udVH|5dmY05+9>f)cRX}(s_}b z#QY5Fe-ZXdZ6?+~o&tsw$hn>zE%iHuy{toswe?gm%pm7Aay0AI(>k&aCD!eTbUq*_ zczT9)8p2+w!-(}(Vt9a@k3Fo*&gjUx4_N8x>~QV3Xn%zEN0NV0`e`k(;b|>#;b|=~ z(al0;I@aWyinyP&6;*56aIF-^9(^w`TdYRARKflYW=Nc9sOyUuNAOcO7@tJSu(c46 zCY5n7LtvM+h>ZIwkg69Egvu9!lMnR0l%UfK&s2fN1hZk&jm&4n;g}s!=pb%(0;EtGPyZ~=>d?+ZS!@1m*mS5g3I4NxM z!+3?`FNiX1KKqP-%dp>~1RuhoSF`qqloH$@Lk1JI;8yb0ok8q1>Dd6@)j9x?)wPjc zhEZa_hqTqaTUqykMb3wD(C}QOiSi{8FwO>RfW}f`f;=#jHoZ-QZCa!5-O(gW)q&yXu z84y)FcqEj1Bouq%yLsXv`6Z~vZS1Nt&7p(Cy(g&c!Dlln74BJIOZ@{@5TrhOs&|Jx(=CF8|}cpYP0=rcxZAHuY70&G<`7@M4Jc1Znw>y%Sg(>kdi1coegPV z*_T3Kjp4Zh4f=f^`XzgzKjopX*$e%34;_zNN&W}vsF>;GE^w6z`~HNH<+8o-6nEmG zlT^q_q@y8cWEvQa9f9#rKNoNenUJPvH^IW5uv0gOV}oUE>J-*UcdzKVQNuTQ4q9hO1Ouu)tVAlvqL*aj_9v7r2K{hB81I)+od%RC zI?twCo$lVRV9UWqj9<_&2hi&pJOr9-lB)C0QX`(p_Nk%{Q3H>e#E@gryPxsI2sMJ3 zWOCMk0cw6QdAb--twte}Oi(>?N#q+gtO}14$>qxr_6gW+c5~Qiw?hm-sn?Zu5hk?@}wfNuYeyH22vsdQ0h~bWz!-K7(|AX8;XV z#;@0+Pnp6-x?YqH9rqp>df4*WUqAx9Z{el3Q8>AYy1?gdf)p5_E*I~GPh z%V>Xsyf$)^8$rQf{tTu27nQ3RHMj6#kho(#gupKA38Er1*d0;q5^B&=V#L{lmvJjG ze$9+TvCD|D91hLrhBy@Zpd46>4FJ!|F({xjs~v;jAEA78t*=*MJZcXH3F|BM_8z@i zhQ(s|Ml4s#=pF#d8m`3||2X*c3V~IF$nOBK(D6t;&y|YCpnL38_gQ?8un+S0*%qLpxBylyx>pVZ6uaw-h}X2t|CU3sDFNE~FRrsH|5)NfbNc*Jbs4%j(~2S#6r6 zY}lWb*q3uW`UqxWck3j?NBf`=Gii@L3uA_`BQWwYcZzRG;aZ1EGv@ z*o`n&5zW^2)rfH#$m(DtjhKRQlmgdkLbpbc#x!L?DnC4Vb!K^Tu$)KJXbfmYi`?7~ zYg`5iu?{(S#N~95P1(d;L!DUsONn5`14@30_{$Q56-N))52jBW)xDa&dfX06H~G0c zuW!9wKp8$vCt4G%Ex;s4Yn04VC@!P)25DkAC|G`~UVBoyCh(-$xjc=ilRoL91YSrD z(hI40v6n@Rfto{pNll2Sq5Jpg8LRUJO9qS%*garjiG3h6^n7iCM2B+B$^H9U>D*|$++R1>B8(_qTFyEb|Kb& zIi?i|hEf=wsoqVpQ>w!~-wFGM5@F!${BB~>kBa+^cN0&b#=uX%6IOJVD+;e4{TDgA zFDN#7325as;ZQFDjg%&=@De06QKHlkFFNB2=rCtc5^~p&}Eur5B`wt1e1Vz;E zgFzlP=+r_<-1JYs52m82o%Rw8^|-+_@qB?^ zHOrHx=QuTo!zM4k^CY_15zv`!(-MbDA^O7ZX=o{IxG(@O1`ZTY24BlSxZ)L<2B_lq|=iC9yv@*vCt$w}| z5XhXQwKlG#E2C{+ zk93y&9=0-PH?z?Mn5q7h1*OigV3Y5l^3`)x?0Q7~UhN8J0jl9&L135l*G$6`CDZU> zGcj)uqdIC2qnhY7s@FQo-kFh2l#J|NK4-$R&PJsyVgMJyYerI;QK>KROJ<~7`+sih zkDG8|e&M@jImbdRx0QHfB>S5%>uCNbOH2KXdL(WX$J8#eB|0 zB$}a_kJA3p+CPT;vkbc$O~;)t^Nyvn0c!IgR#VEI!SjfK#32)shD=Bp9on)mWHyt8 zmhu6M>){JQhhiYWV93M_JeGLz{;^#T4eb7K@NTCe{(y0^KkPY$nJ|o#DeO$t%Z^#` z(E)zXG4mcwcDy3UFTvzkA%1zl9sn^2uON{W*3UQJ@;=`TsORi=?+6DHc=Q;9cJCUV zHxPY|>(HmL`n&@ay1klwo^;qu$cp#C%X?cW7_jhe;010*1nA}&=L!~V@58mP;!Q}; z>wb`gA>K-+Z|-@;1ucB&#v?BH+v4NY5Y#&1LJX!StyW0i!)V>;kV^`H#E8Fo|jiqA$`+Dj&; zBY|gqVfaz!6fpu5@j9p4B+cc={!T~p4IJq zMXeR?TfMuTeBdQz+ z;L1>dsb7wO-#~U?s^&6PS^KF)47YMPo@;RvXW<1B?un`!eCmB^h~{eboVQ$*4pLcQ zL!+MliciiPU3hGdumRZPzo@jRY?PKL^rf%3 zjpL8Fx$wP?oL>+p3<8`)v2i95r;mKaZR}Fw?WBj{U$~=VqAw{?loJuf#_A$&_alDR zcO>7kb$&qer()nbV~|mHlu=Q3%yeV2Iise|X*k<`05IBcMgln3!bui`m+FV^0N)RP zAnM!n;mQEYYS9thWcc>K;8eGjfH&M$3fG{k2^~0a&&0|~mVuTNF9{{f5h(D8!MWU2 z$WT^P`~Hrw*Mx9w33eavqi)XN!V`A{OLc@mCMTSJ2ka>j14bU~Uc_MM$J+#cWsFn~ z$u>1yRHw(BQ^cU#)tJL&gux9$8B^auVcIKygvw0e?oc?(T0mj-_WUWxg^vpcM*^_{ zGg2szm3k173qNq1<$VNpS>F($63MF<5hYbcWx?0Qyu!{vI%+yAg;AW2yZ-Gaa@nm^ zcceQbVr6$RZ1lNsu&pQDR9`Tf$$oHiG(pS7EQnK8s~69Eq2wTNgpz|v>}pUj-nC(p z4O?wgA`A_GqDa3M5!jmy9ft|ivWG*CN^05{Ac7aBbP+WCTS=X(F4NOE3&H(tTGMjU zP!dD0WnkoIcRtb|QKH_LInS&twjyG4LYPD-D;# z#|JDNKm?`W2o4~E(sBd`_I^(C9`fGnISFR%-#RCmjyf2OKCI740++j@u(ig!hv`#~ zS<*uoy^=zN3f zoX$6>iWgJ$*3_jAMtIR2h=DCB`zlSL5-og;YGo5_dzV#<>{E4c?4gwTDP|JGU|2mv zQjZ&))6syu%BksZR=!?|>c<#K)~O_(v1byaErmQ)n(nagd89$J(MCRh04dxHUqn)H zWeZutGBjN;Hskq9+cx&;vvwR9WbhYYlGsatZ*OOTkEhM7C2AJVct4_!ewUH^t()_=IVY2ADQo zn*?b*VVt=hwLo#<(1fW3iHmVvYCfs9P{paX9_`30pwG%_upQdcg;9Xhh-;CTtGnq- zVR;y?NeAjuxXf)WTC!KJy40COgb8HoU=6P4KLeYn2n{Ii;=K#zbcF)SvZAEw3YDr2 zk1$#FbF_c1_RrJ)O6{MoeN57{?xe4us$Y8DNfJ?WBoL-c@@NN4@^GK2o#fH=C6Y(i zmq?zG8*FEJ&<9gE>v5s>S7{#uI>%qEeXJaOH7}<#rDVvIQXx}HM43_|%9IjOrkn_w zTmnpmUqgPTH7OcGIJR`*r9>=Uc$xApSKbxMyHa^;m3I|+biZeVt_!}tZUYmlMVV?hQ{AI+@gURS+hct0SaWQ;=I=xz!^Uzc+>YY=_>6+aeQb}g zCnhTH+x~aTzFCNK|AWT&2<%Qi#k)K;Vna9d@AabL_mGz`irTrfZ5xpU4_$)ocOhWJI5rl3Z*hhv$d~S#&?g1H2k<(EAH`ej z^3rj)D^D>*>2i?88^!j`B)8&cW{&qU+6eQ`F~ix&;=z(?@ckv-6bTiUDp zpe6lYLjBNxHVoi7ZmqMt1Pp*HHwL*izeaP?MdlJwLM|C6#8^V6P*a*3h>mcE3u%1( z1Mv!QLYLj950CSZ9;7G*d+N*A;Ncqx19`*FMHpLBG%Mx z$Brtq#=VzvrkS1t$ooDwf&+-S-;Lk^A|9X!_z#j#YhEAs$7a&g-i$oVd_nuPaKgZ2 zQWazJHLmI`+PQ@T81GE+ca&`i((t!w>6|1S&IGft7j8mSb|Z#gdgpfHkEagY@cv-GBigc{hbE72ZH$GkGUG zb$6%*g~>yi-S4~BVm{sL-rznY`IU7O*~U`HqMzOy{4p&G>zg}}T&<%_XNi|^mxr*? zOW5ckyx}Em@(}!2y6PeiYH9CU?E&CU`-g`SmEJ$3^<9nLVkB>;49#Bw0iCeCtY8 zox(7OVColU6ILDIAU#cX)vn`IJEN(o^c@44_(p6-RZ}U94IVv_Rq>>&$(+!rI9}m~w6>2Vtt3 zc5)D=`e-Mo=3FB+4tXeo>VyXpCZe9v>r#J4&Wj!*c6U~f;+CL^eM#oa8a3&tr_qUc z5lzcuT2ZG{mG!g4`504&(s;4p&k)GxKn7psGx;7HUV-=uNfP+NbTli49bq`zWgX3Bs57^TYXB_SYl_pYIPR4+0ymfnwl#0(tT! zL)-|(CJnL4L*SL*nr0T{6~icNZ^p?;0LK>k5r)Y_j?uOiNvms%afN@E^(-nRg{e4P zU69>Qgh)1h??28rUJG*ab7J;kpysFyLtL@~9~Y;lVWo$<6PQpJ#tV z1qtDJyo)MHUdNK;sgmUFS&}!XnE7F1Ktit<0}~n*LQMTy;}N z`oW#>ica|9PWZb{xbMv!<()wIdN?}&&@CPDA3EVPJK={r;h#I<;p;ofThalyV?&(z zGcV3FAg)Utj)rZA-C(($?|zAxDfkj`{8qYIQS2Pbeu;A?`=!o$_RE~t*e`eFZN%5r zsb#;LGll(%kh4q$!p#dADp2D5OaWEo z=c&l51D7tuq{J&%YD-$dQqz%7^+G-|<51-ean-+ z1+C7AFgN=}7upbZ9t#HFmA2hW5p-V3;2|4;Pk^IsdmG`v#xzbL=xobi9!mz_ou*%a zp!2s39=-|q5;$7k7lbElPUB4oIyqa?_yh!hk;*#qxCu95#T4_ zXgv5);H_{pKJYQ3!*S`4178nE<1T*&J{^w6eHUW}k) zJ(b4iAn5#@!6$D6{t%9q-}*H0!*DcidItDrI2uzD%wV1y#%)j2d2VkVW?wA|W19nB&om8^iQ8?QjyK|g5C^d%KT;~cE=;Dsuo+(66 zD*5h^UEn;em(6w=-KSjF^k3g6`9J)LG1sCFC`=;hp`0==DosetYD ze~X#>xYJCHJI%!1X(r)JRXnxMWhzkTPBVR-*HuhEC;x4hQ}2vcf&T6cG{C_%5O)T8 znHtxffwrreq>WmfW*j2Ix8K7wllJRUZ_}*9ymhIMDEx}%I}~eA+EKkh3(sGefgtvE zEgo$6yOsw1jhS#eMH(qQVhOiXe0pQ|31#r6N}=@ZZpQdLk@j|!6FsBC$x-Ta;(W); z2~{eI2EUi~@jQ=szb0O~IY7l?we{7tZYJM)NJkGc_}RT_->w$ZBM;smJ7#PU@yo{l zQyS{})eY!3puUM>{NhBoZ{l>P2Of@$Is)ghBM?4#o-=#StQ2u9xEg=Qv)bgAA6^Li*iMmhMn(mfZRe2Ns_|x)kK+^CKXqYeV9e77PSNv(<1#s_0i7c_SWlZl}@e-HrdT13EqnnBI zpqBd!K}9LTB9GhReAav)uCb#bEi5kS{n{`~d{%Q4KBV-AB8pkW?q3H{_*Qmja!eJw zPjbu+98Pg~D!XDZmE~n_wZC%hoidng^{c99Apg-gmE}P$b#w$t?hkz|@m?Q_pU3Wn zzB}Ui;s;oiB`)Nc5pb!b;~R3tnEVUksLvt9KZU6;K^pb0cX;j1BM7d-y;C;6p$YvF zJrAfIeT@+H`8;tH+KLc5GSGP%q2B^kF{eR)wGyZr{iX?g0TBdhME#CM{|+)b3#A*2 zaVf@}lPhYvH-WD^qhrv|n=mT$X7qU(p|I$~=-(_em)>WB%vYJSi|8j70Sz6psJ<0{ z`3%DW(D$0A&_f#aXW9;y(uHo3g7eC*btr8Yx=RRjr$z%A-PldhFcyK9r)h&39mXh+ zo;85>u13v_mNJUac^zoqFv`dI2%&Qs71DDGpyM^dNDK5Mqarby(Jd8}dzAhXG-%D0 z3XNsdhdF!VuU61#{YBkFb**?SeLUJSPux&Ts5hR;g^=#GeIBYCi&6D3uBCwkiPlH_ zkiWn!{Dm~i@3KK8r5)DFCfoF@w zK*tWex;LS78I9IxrMM2dP3?O%nsuP~6YF_35OH3>GHdoxXceRPnbs&SVf3&@*K)eX zzAtod#WO`re$eGKjqYUBrLT!kU^a?-IKR0yyV1yv;vv>0*0_5B(H>@*--FhQHhF~6 zeKw&#h$k7H%(Q*Q(~N%VL$v+GbBr!#+Wz7%jI#R??O^dQuBE>g?;g-c9*n=0NwxG& z1JR}cQQ7~SAYG0Sxsp(2e}y8b+&u9JXsw_XF?x^DG*QBwMRDSsCb}~1Va|P;sATjy zqZy(nqr<`3iaS7YM&+#8v7#@dkGXuaM1x#{Ho7|@M5{PKG%;ERgC^A6fi{HEJajdp z4aHxC&l3k?v>?xg3%mtkTfClc$BJDq{L(y2AYQ)#=<_PGWsY^XudeYlkOBT zn`P$hL+Q>Ca~OSv=fr2#Ad7@fI~yjrY9iG+9<2cLc9jX+dqJ29-aid%_R z<(B<6=FH>og0_k~#5G(K_c7<4;yNx-1-gB!xL4fnN%xR=oH_AS0kl7hrx_Juh;4-h zKF4SVqix~^mNJa>d|Ld)BjpA0x`(zMPueq@y&^tj+91yTb@4Y3?M?9y4|+#@=0Wd^ zuQ>N&l)n}0xbI{y@pb>x^LvSRs@ma7dr^LsxU7oYxsfGsZwQimV<TT=0LDwF2&|?4~%z8&(oj%!Y_c^(V*)G?Sd! z?EcV1;RJ`@;qdo;C}uN<_i3TT(hENe*8J z_x>QoB)AkSA~zvsYTj*d{~h0uZ&{yOi=fH(-M7H4?Xd;%!*j_!9VM+2eNYeeqHl!w z{Rmfy{&^1|To~D!KSFq|E~T`pTuSoSd13IJpH1y} zMHc1K4A(8)<1K{+lNN=$llz}4a!Wa!pD0AC&vQ!Po*W|gX%4prDLlA?o_QM{2e8ty>z0Jvw0 zL*afbrx#$=!>ySc*pM&9d7%yY#D4;){qg5zh?Cq_b1rh399jT3CwBwNJ~X&khlzhV zc*5d5&TBQom&wcF?l3RsnA;JqMGSFnM0mcu2WkHrrkd%(rT&K7?o@8Cm3faNek#}S zz3i5=J2yx*uQ-2+X908Gnfvejda)w-3f#%rx$ifUyQ&|#Uk0ATQ!Hi4H^NRPEjqe{+ws$~Y;R_oYK zF%(~q7C#v>*X5i7cWjq4;r3v67F^0@1*BajSHj(4uG|Yh@mvb(KLqjI2_CY{wQx_) zy^$r{$r3iPgeN)XWrY7C-hg|F`4QX|{?9r72ZZl5e}?-HkyC^{(D1UNiIo`e#q#3a zxU(w7 zr*I?wvgacj_3BONDUIrS=K=l2lde$g(6sv4M*KCpk3F;^@tvk!9^Hst!Ot4y^*kQP z-;>I)JXq0lc~Mm4DujB;!ycf>@RVeu1%H#1D1y-hM5@>ZAEiWn+*K5xA!C5A5OVjdzo=BrUIA3~M zb0!9#SJV|JMqCpp`-MP1rqPtsTA*-*;N0(S?mS6!j8Ur#U6| zaknt~SYA`LzNokG^`bI-ET68ttH>4!?5BiSCH4($De5Cu)8QG=`GcM*suP!E)9j8m zeZ>uoE*4{bFBkO{{E9m4trwa^C2!pa)?i3_~K|csh+r zqx*=jHHtO&h_>L|ie#=4P0_y5kzy!z6$%ZC{z2Tyi1Zv59VOmWD0oKxM(mhB(CF;^ zvC%Q&6O9f+&lxMe(&*&q*yvdCAC0!`GcmfqFtFdDe)Q5llYp``8ae35=mDZYqw#}g z0+lNy-jC0TjuQz+PYD`P#);DyEfxn4o(I|wjMfBSX=#fdD13EXhTt}!2_lctQ-a2& zR&kC-G=8><8yL|Dwk&#(=+l=q6Sp?6j2fO8ahSRVi}{QDDBHY8yPJ}O}rJIDV}4rs@UIej{i8ZgV7q)=ij2oi7(UW z)97r`1A8d4o?ENFj2g~;$7qdsIx;dg zUwpu5m3TEiE_SN;Qlr-kC&f+|e`=)sR*B)mCdJysV;UXNI4RaH=nWa7-C8_7cBaU~ zQ52!U{ieqjiL*4?4zyTYrqREF&JuHROhue4%BJJn7GGjN?v`k&_<<2=HY>JN9E05? zagt`s#XOB(FFZMRw#aW$wBf@}j-88jnnL?Go*Y{#hK^9^&HA?3pTtCs2KQ@=T_9f7 z=>6ul*oEThk&5&0{mzQ55*LnEC^D=qcCk1P2Vs=^&qLc{tHp&l2y^wkL|n#*^gK6q ziSUif&@L6(j4)!N{Vo+JGFl~GFT6Z*iQ1cD*N9s*x-xN7 z>^iY%qM}V}x+!+O7}cuK@L`w7ZWN;#sS)!QF_DqV?-sE^b5ee{ipMmf{O%B=4pLHP z)m|RkAl4q7k-14+%}B|-hY0vRl@lo05W7d*qBz;+?-3szLbT<g zXBwsIcL05>5Ttwp6rMyfKMs+ekBWRo%Y*Oq`x&TIA#etZ9~J#PoR5pfG-s^%anYjD zg4*stW76qtpqZLRQsVTi8Oh zr!<=0V;j(m8uch6&NnrB4|B&>^{N8u`uh?>_F-Iu!PXLzvX4e{dJ`I}(dDR#t>O?y zv=ZMJn%$yk;>_YH#m|Y-DJ(^t+JAcS^P-;78nLn{EoLIbFj7if@D}F^B zJeAU|5i?p&EPg{wOQU7QZ;Lr;bW!mRafwDp_g-84fw)b8r=!B_K!;D zqrL7e-YLGtGecSz%xrk9_-|qbhI-f_ukJqaN&@m2l>%jYNcmK_Rr}hLU3WutrkcTT&vQWJELU!$3bXq8WB; zNvR|mH1-_R|ILzaF7lrh*x^C*TRthNa%nlI#J?-Si|RUEm;Spw=b}Jn$S29|K58m`HZItCnt~1aEmNvxn@jhVho7QQVRVZa zD=%V1b@oW<0rDZA`ZdM%#c6l}|HL{q`_fa~h>n z{q``~s1W+?&eF+py+%^}vvi8w$cXywS3vJEqJH~B=~Ve&MrvhzgbbWcGF1;aLUv)a z1aA`!kw?g=M*EndvLj@jMz@N*vT1UhMqkKS*^zPzBPC_JoS|uV7g6i$cMj1=sjy$%i%is-UiHmVAoQ$8vp{6vxR| z8L8SmPF9{lB~rVrhr1?n&|(jcDI-l3c)u=D6WybL479 zRD+|-lJaUsss`uETNMp;EyY}UH=`wZ<~qJ?uKbHeX9GF%ZyHTC$Cu5MpQqDJDmz7* zZQKsQ?FG}zPLo+09a?*h?=)GU5OO#cv_6^^3Ct}!L)LpZ&yY=wlxAnhebecrI71%D zXo)Bk@B7b?M|wEhJ%+}~Itk#yvLXCQ0)wN8PD}?&I3h7SNwA%yQ@HWjnjVQnKCjMT_}rM!mG^5CBv?k%}e-mK9Z4ZF*(lp8b}SRX83EAP|j zfcgTU$2E$8c9ncaqaL7LC12L)fqqrxSIf6GI=e6qv{NCmy;l=Z@mW;9HDXP}$ntAs z_7XyB%vvWWGg33cI{6PqG-gdIzg~W;(KetPWpJrVM{DSt z6P7V2&PryLua}b<(Ts2s(9MigOW!J=Wu$E4R{44d+73ob!~%0(`K@xNMsxga<+sVN zG#cnTtNeEPy+-T(=ak22P@I#kb>$o6 zCyW&5M)|F#^)T0$ZU4FOx2P4`^NwG8qxZ5le|GAT7Pbmw`)Y}&rNbOBULY(Vu2aYnN(GRjD4wncW+h&08CpJ$-+f~EbQ16rmK*XOCsdmHYl$exH27lkR@`mM7i)@%pF50Ji3Y8T+Zu@N(yhq3AYr}2a`)NhK^BT6|bZz{`wZ;B-dbRf`1av7b#x3 zpYKD|D|+IUT=5CwePTM^e)fx_0-P7lU8P9%BA$&6Dt#ucl5k`(QR}%x*CCbqNwJFS zFeX~}=Br5syr%CQZ(yDjd`>-XhCX#+heufNt(UadCe zrDPt?b*uFGluM-C6?jr2g>q+b>x^ol7!`gMT0tMKlj1?7;fY*hit0@@9i?znc_r)_ zRx!WiD#`Sbcvss0Rk9)e(oE94Ig%|I;vSCQv(&_Ciq84EF+?>q^_RjKnQp2~j9ac> z&n3gZrvx|VeC`Wmy{1T^=laBX+<$LE?O}ZAMWw!td-0iQeM8({Pcg9)3ga?Rhp;Ig z;1;}{+xqo?m?5n3rdXk!5*#0r6HzUY^9Q3v!?19Nko;$@h&U z`L|1S64agmH!sYQN6gLH*u=*P+5C6_w?c1>oZ|@G@xODy~B%Q^o&?IyXgCFY3QDYiR7EQOHfDsJlz4Er`d@Jhai{Vs(A11Wqp?B5-`8vGQ~(;{kbo=4PZK$c*#CAhYs;z_b=8xHdUiU`KFNWxcxzFSoP3jqK zKF_(|af|#fI?&vqQc*6j0iM5pDf}+vyCdN+Sfd*ze)Ut@DmlL=#x32yP{W1@@+|y$ z5w-hS(8MpOFW}7r^sj)Jh4u}K2DXQLICtVSna9UGe&(?>5A{lS-1FAqcF5WD=WR_l ztj2*oM~wfaeLJ_HR}*h|;E3PL=}om~_)E5PH$I5k3*qik75+L#ck#LCjT=FIaKmMQ z*o^lKHshUvS4A`a4-wt)6|FikLi{8~;{Pa-E%(L$(fEHLZYH&gYT1h0JxAe&$Wi!< z4M#!RQKA)owLBVs<>@#mk3(-660{qN!1d!6kGjFKyKfjb^yv(}iQN(Gj%Bx%-6`zO zV0SiLiT(QSzD4334zGvX2VecA_-Eku6)$mkgn|1O_>0jbc`@9h#pQ4%P7mme?mC0^ z|D(iC9DQDAnCZW)1akv&z;LtaU_fOS|Z z2Kz6POGR&MjSQJxtFMqVB7k3mlZ>&^NRM;PbG&1J_K zP3CcfPcd%i97)gR#tgXwsb^tG{>bHuY()Z|w2 zT4mhaDlTq0Rs3jdYw2e`#5rEa8cva81|MWT&-|}4e;*?|KWVNNp9SWduQKO{a#Z0R zW|O(BX_NUbIJcQQne#{ac>lM}&k*x3^IMMjP@dgW`a=tj^dd=uysz5ygrw?ljbCpTpB)6R1p6srd-xW^t|7bS$nBz|{e}efNINZSDp&TB{;q`JG z^lad?L)n$SyR7s4(zm1kD*q_9XK7y9e6yeI{8_kEGd~&+bl;9}_rb6EL%!$YZzG)S z{yy9z^LL^|7ZryP?lU6K8Yihw9U{p>4(ISO9RAUmm7iyw$T9OcW`XQAY@1jrsm>{{ zJFJyVUCmT!o>lmTwKlDf5x9Y=w=;D!r+tX2TRHxDj(=5B&w5o-&w7{RcXIp;^zP!| z$p+mxm?2MT8WjAD)0V*U#|KNymBWq;o^F`=^Wlm@z2UoQugktNK*6Z`dS1M6jWABv}Y0Y4g#R6QP~dV4Ck zUOw0Od@vglJ{8hDspTJtp&p8~cuv1wJ^_n5$LLYk7Cgr|4AOoy>PO^sOKoGXU; z!b5e;n3nSJIHN1-XPj}^kW)p8(Y3TKc!~^J5Q?)Q_HF!S4jX$c@wFpab1E-SaJuQXVYmJ~}d#tz-Lk8dns4 zBzm%ho-E-rjQQt?Z!rs;Dt_Xy&!liR`m7X%a6c90aKFoGg#_Hal)D2GF{DGeNjhYk zq*b}O#Pa7BnpYHta(i;B29rwNU{a|YFv3joKO^ZT;!f75L=J8&_f7GYW*7!E7B4Y_WLa`% zn(m&VO;7izyGJm_%IOwz9FC>yIEk*EV>=lFzB&F9C-I5%aGb;ttb2}gteYsYa;{=I zhJX_(QF1a}Xss#U92)visx?QNjW9}*gd zgoei@{J4bU5{^qaCE=8WhlI|@1;z!Y1m;n%rM5}!ACT}@)%fxsUGxknIjx=*NieSk;RhX7OR9N>id0$^VKKY%Cj22U7oX#Fq1g8Em$ zXVeXyVZ8l!H{i2sJK#^Ke!!nrKM(kE^?GM3-oP8`YE|deqkso3hKDSM-);Q};Nw;d zaKt(a_<;~(3n9in6JqR-hsFV)4P^m;BE*y*mo%T0G}DsioZy!?Fz*V$F3iS+w+LJ> z_>F+@X*C>2nx`5b?OF>P>|?j~;0Dx3yLxaE`~5ff;B4_Jz}4#K0XL{$1l+3r9`HUD zS=pod)JDJu)jI$O1^*b}R#;{IEBjOo<@CYod$em%FfqZz1d{+Jvh0*#P6_6WgwNWL zxz6Ivy5}RGmXsF+f6<1Fy@=S~iM$}Omj!>thK#*}*ej8%YD?(BmEV#y7A(X^yBe%6 zfjPh?i!^i#ezo9NTg2ZY_+G*HSzFi^!Sq?jRC{-yr0Ew-RMNzd=E0RQ!Niaz(jAjD z3G40Z)@7$8_LRh)LhPRIQxf}(McO_n__LDctQ}?vXC=+21#>}axrn^!?u&wdLGYIa zf5rN+dcOOL;J+n!D>TV+#-?Tv)kqHamE8fiY?y;{=TBC)-K z?*snp-F<@Z7kpIkG2p-59TR*}FsB4_N-)zX`N5TE1b-IzpY1*?_)kj-=Oy-n#9l;f z%c_eK`+~%NCG>W+C2~n(FH88cgs&jwid9!6<+mi|>uAgUk=K#t(THl0mNu}oh6ZVA z!zuP`16#Vff%L4l!^hOtRjVbPBe`UgPiYQd})%$jDlYfUrT)hn@4fiX!FlQc!aoD$3_!JHAy zS;1V8@I?tt#&E7on@ZMs{7XT3Z_pmeZVx`GSb0u z5fyw)@G;;o+)@yHQShe(e_F!Rfk5+0FoRKn8|K7%l3RSBOLctK(>N%*pa)gq~7k#Io5-4fm*;a-6w0;2*80*eBt z1)dRjUf>1E`xOaaTEu?5B;m_~e|-^qP%S22EtYy0v);DF#76|vz4)XWjdTlsz2J99 z`W+J6E3v&2J0kcI!AAvCkZ@7b6a_Oam@^VSFX0OkzARy@lQeV-+|fx{?UnF|grgEJ zNVq8BX$hZ^@CAXFI;l@COW5jSX%T_l0(S`P6*wX=DzGTd>L;5LC&v}k_Gk(j0!AX$6RLwo)^po z315=%WeKb6rG)F5G9uw_2}cDM1x^e8yub^BxhzmEm%IWSm%m-DzcnJ^Zh>o-b2Rlz zc$b7nBpel35LgsAE$|G|M3!9;cu6pqC46=HDYQ}DAax0h2<#TvD{$8hOcT99xFm2| z@Mk1^{szkAdBI!|cv+xzBhz;aTyrB!=#}uujiRG&WQ|e56a}6Uc>cy;R1dAZAmPgb zt()Gia*^(vPU8LJ?weR#{H3Om2MnW?CaxCA?!L%O4R~5cteW zrg>&1(@YEIoM6sN_>w>sVXlb49RlMK=88v{t00(X1T!t+^ATyggfB_>l7v;al+(>v ztV>Yl4hip&@QA>Iz-fV(BzDaz*0pAp*i@^ScgJeNFR!L9y1JTpwT7iNu3g0!v*zvU!?*4bOhMo?YnW?V!sjIYc?o}6!j~j`Rq|eyylZY@`dzoM!j7|q!kh#k?@FwIz-fW!1zr-UHcKr6M+6oGP76FQ z@RGpD7D*|vAaGjXd4ZP%s;x}ZxRql$BH=X>-XY;#5?5fg=J70xt&?I4ysG7{mRQSp%PTG4YgyO&TpR>U^QabB6dBnw*zx0zVmxG_AT$hKIOgY zHu&1;Mca)1&iire)=srU^{HOms|NL+>{kcWZgm)#cjIQW$Fcu8q6SqI zH<^KZDxuzk{nW>B$JFDvOX>)GkTD!qJ_`Ti`>BY46;U9%oAyR-*z%UZ%auOs}_+Xz>$Vftl|& zyxZ=*8}K)_Yy?d~q@Xg>zv##(jBmB9I zUjWqf=yLw@o-YCOoAvaOUhp)1aKs{FYg z5}K8iW8L{WN_&3OKLGyo-3});<-ga(x^%xx-|;n{X8wTj_y-n|O=uihX%B79pb{Q1=ua#E+Pl;(d)E^G5IBju*njVR}V zRfJEiCH(z0gr`>%en#L2?qm2j?qgl+wrxdNx8>`1+>P*o&G!SY75ICb9zginrH25& zvt$IYQeRY$weB26-sd+>+#G@?Xiy>Of+j%RnF6>7dIIN&fD2*lF9eJLhciFW4miC7 z{a|7IFF|-6bVLYx;5xt!&=D5&!E%Iehrc}p4Y307K4=ntQ>+`X7uqBQ&2S4~KeS2+ zdSX4`gUB6%p4bRDgxn$MiOqm9wH0N?0YlIdcOpCr7*b=uLKZZ|y$DaD zwvc)fn#fYe0Yli;cqhVBfFayP*NgB;zz}pyA0Y160Q^Z%5yBgA1AxB+T0*!xa3A28 zptVBS+jt1@0`ye~ceot}{J(MMVhDE#J_`61=&cZL5PUD-SJg1!i_mL0GYQ&5>W@Hm z2R)l&m8Jd-5N8x|vctkTks`vDbqe7SAo|hzAYiBUA;2!{G~g0=*F$Ql z^&H?b>mz{6t&ak(uzm{gX6t#tmDa}qBi7FVc3YnSTxER`XZ?9 z1H_jPE#BPN4~Ub`)|U|80~o^X!WR%81`Mf;brEpFdI2zN{a3)8^%cOP_1^)Xwq680 zW&I)GGuBIhAGH1i@W-r|0Y7B@55OO{UIF}%*4F_)Y<&apS?imC&smoN{}1a5;76=) z0e;l_E5M(`sgn@y5BwXz=dHg5{6DS#3HUMV+khXp{vPmWtnUE+C+nX8f5G}^z|UC! z0{BbTzXE>N`X1>2Wx$a76$}5=uL9s~w$*^}e*p~PO@}7H&s!~ke`K`*zGQU({;{0}-mIHp%x)JbO)(XJCv{vGb(Yr(2Lc7&_Lfb<} zuPYOlZ~HkT+?)4)2^m{P1&ZC zP0uuavT1qqs^$&NcQhYs&Nn~R{A10pH2+2O|89P$}vhl)?aD;z1BZzjkG=2_A6~KwEY=AR&=QSvGx<~Uuyqa`_=Zf9oss_I-czKSjV4r zG%V;_@U8`i7QAP{PcQhz1url7%LO+qT)ptNh4(DHu<)x3zrJvB_`dM2@Tu_m@Ylkx zg})vCUUc zh<(~2=(@xBdl-7|5$xE$8+z?g=(G30wt5VIk3*}y7k@v3zhV51;4g~5BlwG{ZP1U~ zpl7y0H*SNb*#^DX3tiI-owyU)W+yDDJ(AS-;P0=jzXSfy+aFbnJ6^Q5c6`xV-0_6t`2Su|AF8Uth2x^yvj(l<+t4TUdZIZwvp*S`q%DwHAM02>o2>^rFv(zQAtX)|bkp z6WiCQZQJi19^SlZc$3=JKc37VNbk&MqVZTXm+yZvkFVq%$2k`1Jj`D8See1C$G zf*Q)~OXQDc;)BVtbTmJib;oUw4G-^1<|b0nslHS+my--qDeD}{>`xruHI9kU5 zcd9+oF$N~kZJK+|_;GvjPN8GDCL zQO3wpwtJah=Q@;lVlt7-Gb0PoG6XuK;|a7a$HFA_?qoXNo5v0QM<57;M>E;{ek5Tu zo0hSq%Z1a$mr5E)k7o9w)0|2Mr^b(DQg#VoC_WF6fC#3?9+*5L^`c;+6WJ$|F?6b~ ziml!>yjg849|Ay0-!iU-L?cB|eVdt8%Gkn?TZ-)n!TY2_uwE&))88S)luNx}t4R@Z zd!)!N?Jky9#u33)l`M>fp=|U?^kw1$Ouc_Hm5LroB}O)@0eg_xPY1H`L^cukBKx11 zjOOk1y)nuwGagDr;|J2IDVt0i%e1Lv9@z1TXf}~`RRM*7rw5|Bql1Y&LW2pUfY8PV zr_%Z82}*{$T=P6WJ}H&=X0y>LBshw?^NDdXv1I~*;2t+AwhSZW?r}TfF5-PW2hP*qYWHM1HnK&DA`#Vz2b)`P>?Nio z;$SqH1%ALZYFASD8O=@+Ygp>R9z_J&OJbZx;%Q9lP@}E4-#I+IRksyCK`q^?N!;ot zajTTgd^Rr`bgJ>By+e&9^23LRcHe`h8`ZiiF_B2eIa`R+uX50=YH$iO z#dwb+skt6|24ZGsK2nDg6VPhAlF_krCYMjfRNM)&@gQv=u23-`pZg}WS+sp$G#wpF z#D|VTd&Lp8ZF_2XIH~9760$cQM+ZPaAL0lZO(xv)bDGaWnG*t&jdpPeem+bIkb$f&3 z?Dhsn9)f^n(mAo`{KX!I*2$)(Ao;<$b+v~QU_&}M#i2wjk;J4J9NV8th!GsvCYQzJ zr%czW4N70{mpEJ@-eZpXa%1xBKQWO?#*$vU)tAs7(E4*rei9Ex^GE$ynPCq_)5rW# zc6nNvf#<_R(cH0|z`7Glid^2fPG{_y@}K!U^B0HjUu&P*nih^GCe z!dRt6(>s~Z=#>O45fI={XipR+(a&MJ@Tc;q-F?yQF{}oBoibpHd!_hCvPmvzeEE!^ z`eRU_UIGT>f~wE?bJ)!Zh$)}@0+Q%46%fH`B@Nm~F(Cv*+wHC+NkHbElgU(mAZ=_` zj@HVls>h0ey9RbZIhc#%$vCXifVh$j^g%72KJ$`-&XDcFY( zB-8nT%(iy))4ne{mW&-pV+0Q$PQ#kU+<`^CKiyy+7D)g)GntJg4rXDpiam}F&L>U; zC6uL#uK>!Zw$NZKsiBP4yIkk;nU>-}&OD9USZ&`)8iuOeaeAv12<* z(_E8AKz^VB3~9+q9u6F^~dG=h_J* zvQ<(H3JZookxLaVg>o9PCz0nmx-S#Ady;_z>4%fKWL~eP_nRpFIFwE3lyA)D2rnDhzgd`npAll7vF3t#+DO#hCI{3C1FvJppZ5i zc|@d)k=}HiB-)AcTubgs#8OdyQL_}mIx8;}Y7ASIH|4V!*BU~NI_nAL=-P5OW@&LR zG)fuvQlp+sY>;W3F1dsmHBl_HG*3z53FD`fCx^BkT||!_LN-$~SvUdWiC!3*Q@LcW zhZdO_P%;2Zn!@;&IUIUQ*lSgR@X4)jlt=q0ba5`{WsE$PwXDSa94AjnanuBYJ-3*s z?2#p@)0AXAEA549RdC@Q;qQLzP{^2;y^4~qP=k|4D0V7m|FRteIeUJW7-IAQkVicL zBnZN^wOC4L4+nX+heIjOy%JPe*RoJ)53^obkQPmY^PJ2%;RB7oXGL2m!Te!I;!%ZSHxw+=M9zFFX=q}VEr~2bb znE%+NJ1#RK49h(BIk#^f9>(mBU_Y$vcs${3m~cEzBvXm3tygW6Iv|0W0bEi2Ct|6| zxXhVUV0{_*Euv$I(wKMrs)sqPJNSXzP8h?Zdy~gp$X$selVfAD{xuHR(w=~mwXB6s zL~kyKHAHG^D4E9!x>N$Z)L2AkvcigeaEU>AII*x-2H;iAx=;s>PUhnuY*FVL=24D0VhVUhkWSX zR4Q}aTLy#x8w@_IFcW)#NpyGGRjwfd!sbTH^2@Hy8&$GzoI(t%cSCR<#;Og*k3W*r z6gMIf8BO_8^?~LD*Qv6p3-=KeXmB~uilfP~N$m-7s_}G+gEsQ3`RCvVsM;qoaA#v@ zM?Uwht-P$0L~jka%oHc8G*LS!^!Z?PG?AY=g#Cn^gO^PfTNiKwb4A&-zY`%glej+|+yI)Sx9}XCX^U*%rKg+-+l&`{ zK6xa`Jw7M4Ump%oJEx%esODwXwe>JPu=+VG-dHEDWXWk%$&_(_GfBy9s`}HhOdR$)Hb1ja;iV~6X=~Ma-o?WgC!A;P&+M_gp~oKOEQyWv zxO+?f2gknC(n5F?AZP+MuH57ZwJn3{$^4Wau zktDJl&L&mn$opI-el^=01H8vxgmN=yM!Ci_JU@X<{V;X1iNVRyQMke}ZEN|1{sUQv zW_#$zmO#m?&9*rYQEn%f5>@eUOCc5FMIPzWR(j>BXvy&~M{<-q6BXA-@qLrI{7x+K zWP40yvdJ-SUQ1PuFI=zIO0MxbSS6Z;1sOA5dJe({`v<;8*_>xwHgh702_uo3(kL=) zFfk4%Q!)nSoJgT+_meGs9Q{}fV8c_=Fqf+<>7CacPo?Uh^)Lq4R8Jgf-#wmE19}~A zGn(VX@mrFPtaJwA0xbTxd^8Z{7S4o`H+jB^s9u*%8o#fe>B z)ubrVYY~%7U&*>9CH==VK__G2rjhepx={l%%h7#j+AQMciWCQdi7cf)kaeY_ksKT| z(4Wm_+(`#yw7Bx-Dc!odZJV|a4?F!~W5MBS|Q&X+3%?J;d{5oyVrh^EyLJimhs z)aOiqLemwycJYVcJ4>sW4`VyyB=%jIWLnvJoU%?!fhL^Y3a%COb4=C^P8`k9fUPUx zMx{8{FfFOTy-E1#bg{K9DFFvdpg!0{jkG$s*NN%oUuoSbF>0vh%d{9@uYU# zEtC#dD(O|X`#?Orn1E3q*dvBvGDfj-MZk_87{^S>H6V^Horoo59}zx_{GeG3J6Jhy zVJzVTlbGqm{plpoGkQRT

f1&py0Ak%+@dvOh7le{$Si7_5k79P9b4@X?8RSI)~r z*Qqx$MGlzo*I}GTPr2|u#bns;s482BNWlY6iFQsw+g&DMCxscovSgMxbb}t5_LCgq zL_yv@#q2ye?#JqNLRlS}%#vP^*gBkYZVtGZXB4j#ZqG zv1}%n8O?jWgnffYquB{#%)vMI1kANWG^_f62Yb1nCVMOrp!fR$7}mgnUkAAXZLfo5 zmk8*I0NfGoAR+ER9{2SFWSm;SO31uIhuijAP;7->cID5x1uLisEsJ8oxK11j8}wGX zIxaiv(iWrQ=aj_ zb}&_Tt7NE2yPPcca;H4rFEQ>NXIDYaX)v;_BpgnPl6b-2W_;^TY>?!_$t<1dN>$oa zE=`DutP@Q?S2E@vhaP*M{U|BQTkVt}hfVQLHxCkExX{$ICq!m;i$C?26QvKHmd+q3 z=fL8wL@t(1POvr;5*b5Yj0{Shy)2zws0+)q@Z^~y7unN>B{H}ue!;>j^xQ_f7RIqu7rJRe%Zb4oj2u;k;)NVm}5Doo;$R8ZlTA7hc3 zl4DQ5v*1q0A)3SYJaI1c!F1+$8e}-Ltd4XEakXTuycDl<8dU>J%6)p*UB6g~E=PM# ztN`5<=ZuWxC^17M%=<)#kj^B=Q?BG@76+Vb8n2*3yc2P0P>VfP8rMd(bC5XOb)|)X zKBRLk>LP1PRFu~@YSd17#J25s3=ijzCUY|+DPS0S*i*rLQ8Gd5PAH87J#|v3xm}Fu zkb})2on@UbDp{VEEWpCRbCyX;^&zw6shE|Lm{SRXoP4n9n2aLU>Fi7ru1VL5~u1EFp&jH~OU{2!)>Pu@1peZ@sY7 zU0{}Z`l%#6?s+cfYyf-Fe!D;hpncR!*lxnQFKs_C4+aHBhF$40q*WCiGo`%I8&}Ov+EK{dRE@%GgGX#Kpd1kAlzsSOb`qQ31%|0cc*vK?1Jr0 z2>oRDm|68|B;4CRJi5S#qkA|r>Bo)~wW#dvk8>}cgw)I%{dajBQ6M7u{&SWwC98joUOvFobR*fuH>}(~~jXU6Pqw`OaG% zcEp~^q9$p+eyyEx_JRFwTFepMXZGS9|)n@*5}b|S~nRm@5cl^x?5n>LO~ z_;!~4$O>JLqcS%M@y_xoozF&Nd3E5(`{3n)`AKIF+AeDl7&tL==vCCU#~z`+9Zcj^ zGPfItMB$S~t>CI{4!SXZ4OUvwz-H}%4UTLOCA|lsQi;*Lf^+<6US%eR>FMFocPSSO zZffK#yxp|Ur7iX*5DO4<;{Z6fOY z7Z0S-rjrP z8hdv+oa0mS7OU#RYu0KnLDXnO445c&0ScvKKpeXAJS2{KEl@B`pym@Nm`dI-qwBbW z8P+3lrKti-8m*MY5ku2QiqVUW;26jL*Ml0u&$A%tVUt}tTWn*45l!pC*l9A^(wa6n z+V2N;%7j-#R_^wWHyjiuPCOo!;ws=v6qR=IOlf6HVuSYSp3=(Lq$m~Xak;3N&E~3p zz8;-N%Z_xuGf&!4JEQuoBzdAMKfw?DBJ(An{Yv z+Dx2KvHS@oukG%f!iKNcG_?&FF;fw#f8n0f0glXpoDOp+?aaidq}g~|)gE-_n4H;| zQN8IYduqT-k5ftxjZrt7X+-pN8U~ZR1zg7pN45bqvlDQk!I9^3XAByYIlf%T6$*3OO?xk+uh5IC61K`Gq6mFX6#Vs|MEO37X4kAblCJ@A8asoE3)UrXuWbqV5 z`Xuh%;gh;=AAYeM0(K0cgZPc%eu~}50}rp{&r8bv2#-tJ2}zSs>exPnSXT@;Xr%3W zcyB+;PXLn#ok3~bDfUQ8(&EtCi=3oBiMFv-sH*`jUO0%`cd#DE^Ele`Fmj|2kHcwz z6T$_xI;gxp;Q;fUKyK9%!TmiErI!2K6v6#OhyrRCn8PH0dk;IjNc(?jX1XQAZG$7SeSR_v>{=Pze8X7gR1oZf$a(uyCfi zsO#7%>=tKS=RlyNg(!)$Eq$*r;fWdK4;mNs*B+GHtIu^=WV7KF+3)DX2wIy0hMgG^ zt;a5+Ftg+QdOaedT&-vLy}t6>9Kk#QO|tEo%E!qyG>I#wdhGG2I7yPYuUMa z47#UPHb;+rD&|q-!4VB$yo@%bGHn#2pObJ(q}y9h5Yrv;Aw8_it)O(Cm`q%yxIHL1-@hv#w4 zRRVR50ha5@pmx^Zs-D0eGZbtC)%8$3fmYF6;-HKmhr7Sag)oR-?_lVGi4c^k{#J1o zaEzr|{dzz8!QZ>zpWYk<@3drdvZbbeKzLh!dwx)RbnY#q={HyI&}a(oZT0lY)nNH3 zMBy;(&H>mpkKzWpE%wwpjJxWFVL=`O+>e_yAHm!L4}-w3})V@2X%3Yb9gS zt;c6h)Vn7vqjK3JoDgVOa@r|ZVo#zTs{IJs=&S>oo{HZH)exSi zd@1xA#hEs|>PSx<>ZcwFBFoXk^=M&}x}3y_h)t#WBPN}yO?f@*I&+|3E7JVXB0zy& zE3;D?%*g{!@i9wevPRG4Q~2eAH3Gpnio7g=O9vy$wCLHvWO{iCw9w7$&Jer(+UqyR zLYZxc2K8mIZR7|bht)daPkH~5j}$U;Cl8fDA+2p6IVIUMWiR9qe7(*PH{WTg&M#+!+H-Bj z=G<*5I)>i5@p&!iozF2kclv@x$=pkw*?0&Zt8=H~2Y0;Ay=}7_v)i|rjvSh_0GLFXKuSW_Tublo*S=vU{`b5 zp}j?3zHUPt9rD~Tq5U))`esHQX9OMLZE%Ij+;Wz}{8zJD6et6^%}@TPs@pVpHd5}A1K$kcNC{b47qv-M^6O??g5D+1G^^55#Q z)%1c_`?zP4O7mJh+K9TpQvOQwV)@)tDgR98B(AhLXL$G5WQR>1zBk5}fl`GL`DBOub`^{d=APXWs7l=ryBs)f1*SYW-H4Gb_x4+}gZFeWfAFfm_q_24?F zPY(UyI%YL{7su++4n`im+GQ>?_SJf zj-1Zd5lq%^6%$6%=l`JP9@sw-}~{wPTd3@Vr~;oD5tr=R5{Uwc>)9Q+?gzuHAGvj@fpbu=({3;=%__RQa#}@KF$1 z^v;Z7-%}s?d2e9DP03yxHRjrHP>|Bu?hph~<(~9*qDOi56GzHhw##IrRtB-lPzko( zXu{>c(0GMUmm|xc_2Evsthv_K2PAmdlLuM&#zY*UYvVw7HMQ_1`rOC|o_0xGqeZ^= z-KxzmBLeP0%v1cFVAj>y8n61VM1j_Z)s%tB$uZ6C4ZRhG7a5AH*9CToo9Nnt z;ZALu=$7&yoK7(#ZzhaYj~Mn<`t|$Vt8+xxuKI!pRnR=%g9D~K6Ig!2L^Yrj8}NeB zKz*WZTA;O*Uv%MkT*P6ThLB`nKj4M9W&06Im%V7BI_VeIg3ng00u}gc5{))yYN_-a zbIqASoT^8ZF~1dlu2Kc%c&`erPmj3?(=2hHhvnJaC^m!KXOP`&%W|T|yI<@cDEZ>b za*`@Ndr5T@VMbQH>c3pAzO{zXIVwZs$a>X**ibVvn}ARbm5T%-ya- z^-Yfu#hTj8@YQQ%8?66Vr&CYA{KGXg53J4S8hR7nvDl11^BUujY(DEl=FRN%xz;+h=ZM)Y$!ckr zZ9aYEeFrxR!9;1 z6-@QamHJdCw>LcQChpDGbu3|aI@U`Aalzmhdhvlj2TRa&< zVRj0@d6C%P#-LH=HkYoYLaR>$xv6oCx9XgrJi(mH8N-g|zPYp@j~K=W$w4K&*}OFU zQ0bT3AK2gA4MTv|YA-5{+gD|14P5WOv8ll80jpfDd-yx6$$H5)wbirEn13IzsXYc2 zpiQf49CWu-n-eNg58X3U7Je^;I!;rO!(6}3s0VI6HJkQ%SEKdzr7HZIx8j-Ua8r4? zlfvB;y^wQb=Gr**^h4G9kfVT=(xx#h%9$xbFE7g#x7Ui&N?4!d)P@HYGbQa9{+uxF zD=s-Epe#6PIrdaJy;SME;KsNmtJhDT5AIwO+l^)O;tiVr{W#{vGt!PnoAvx4@Zk|~ zhf5iKp_Jwdy?u@fed{@*)*4Z+^lPu3+f2MFoHoH)zg{(4y*q1(ljC$TLI#&&zwx5? z;N5=ujVS`0*_>Ov9ue$OIXbU}FkL2w>OuDytz1%N)#8Y>YSAYteqfjce@@Na8`F)t zyHxQ@22ts^zD1t%{`~=n_)heXz7v5KFIOl1vU2A;{CA#(n&qy}w5w>ztH%utFX7##Mf* zuTJAeT~@gu9WxsRaY%ZOGr3mKZ<2Ce?jT}EuqN09DD`zt}}ZD!T^8-nkexfW%556W4j<*tcs+xWCWk3}Nxl|4^U*<~$s6hGRrS{EcT~Ggi>2J2lxo!!4ynMY3AJb}{ ziO@VyIHNW{T@LT$(;YwDSTz^^KkZT>Yw#?Z1E4>gFkpWptxMS z%SD6cGQRptCmH?oyhGN}0lKsFF8Z~@F`+ zpQ567A_{AUOFOKhI?U9Lk^Z5R=E3~B&5_wwJ2NAu9@e-;&`=sIiYC@O8)+7p+X<*v zy>IN#Z#UAx<7T>E)f+$XY`N+v_#keWcF(2s;LDdy$>!I~*?KwWH$LfA=kesA;q6bY z?{0{c?wBbb{5qaIs>U7D20g6&weaYG_m&pFn$c^WYPEQ!%{`)O*I2FG>Jo3-=ItLZ zEwh(=KjpLQzuEB9w9MNUKSfUO)hh?}an#gr{B>Nt=o^57WY@2ji81>m?g{Gw;8R#c zaPra@%Lkt|!oxX1+-?2VjU!OXGuk2pax>~;{(Wma~aJVPQ-d0Ud;a5Ff^Oc0BYV4K=k55CE z7Ak7!;A^?P_Yqan^nOhjEXF+PP@RSKiHxQ?f+3Iq^YjofEvocu=7??xjWc|_H@rOz z`$!*I=B&hSF!%cDn(Dp&puScZN~v%hH;DIsJd>uzh z)cSR8RUV)dxV+W+b4kJKshYDIyLdNNE>CrqD-l)rY%NkvJbiDx8%l3$1XaQqbCsdV zRq3~SR|UuNEZuLG7g*UHVWtZnD%N9!j$3V?L~xde-#FpQa3kb;6mSTs#(~rC)|n3h zxDNo=`+btf}sFSpY7 zD&=aqIONA6khF))_6KOZ#ndec_{qQRTnoiZ-Y+z1>yb+kQ43 z1Z&+Ng3>zy-T`PFPHNFU>{a#Qy{1j_B^kARA2c=<4d1Q7gy zlRQpGLT69i>?p$A>0#a$%;)9I8;!Mnd4Eq{qxAfWNp5A z>z^MkZB^>MoR)iOBX?-N@}n>;i<-sDN4Iit_-{RCT3)H-*{YKAfqN$o^z@;h&DU%F zEoJ}e{;U4h2wU#eo@}u>eXqZytM{Yut<%D(`LC2>K>Ja%I=Etf$46^pdr_?;=|YNatSUE8So&T`WssHI^$ z{vN~MdzHG5W}5%}k!sQRgYeVUELnG(TC@|&K!44b(yH1X#uKk@QXAdIzj^6TuQqjF z=N%I$4&1(=Pj0Fu0rteQAmLEgIZD(sTP|_N(jj{csl$G*m5a$N_}0WXmQ~>srf|1p zQ}c3mG;F5aPeGURBL*qpb*D{&Y32jKl~Z%x_R7CDz4RPpI$kT4I7+9ow4-GQYqlCN}MO%@Qpr`(dCN!L2vtR9+MIRS$4;M__yLbnZGbai-cW%;R- zQtvM>HAs|uD%e=6cP_c5{zvL7!L4ciwt{6BXKqSQL6t!}Xd zP`jc2_Nfi^)2uesPl;-{9s33Ke%GDLF8_Q;|Bj(f+ssUr6}NX*Cgytbj9|&B?yp>a z@PgP=)15QTJ%YD?R5yEO6n|O#>GL_%Bt|D<8dzPeecCssZloK&Je?i4*~HaugPr4+ z>N)IGvHC_)y}j%AZ@?SZL???{78v(lfBiv|bft~sUT|C+mw}~E&8_qytR*wDo5{sB z*Qwe%$KV*Z>Ci6{IF-Y#)k6}aS3)dq0n`QcY zSX|#zuDI5wUy)pT0vLU3L>%&9Eu?A7LdSR&iHb_FAt(OBGN3OxbD>U{q3-Z=)gBtJl6m`R7V>;h(Pc4%gpKBq%hkJ+du@_ zF^6XJbs#iU{lX8sRe4Ud9yveQeuS#`(IJ;p~wuatZL8OQeB|zZ{;34_ZYX0S9yry>24^y{j02TubsFN65dUeZPQtrg3kdI$k@V0`|t$mUll_{ikWGr}8x;g9RrM6}K zv^y1A!ilb?DLZTC|!sWzj}8 zqoI5Ppl0ADwf!(TBDiaB1E6jz-9Yqq@XJ_k{+9Eo)<`z#y<4fyM<+Rw9iExC90I3< z=|2eysd4lbbGk>I%jT+6I`_VJ^eb!jzLZEg&{~o{Co@CPq;nj9)Q#SJPT#OMjpp|{ zDBW)%8Xp&DGTP{rBu?t1IODLYY(h@h>srS!W!*#QQ~HW4y%f0$Z{ci5Y;|7Vj`}Ol zq`|#jZrB9Rh;FT+Pg=MS0Stoja=x1uam&viTYfDe`DQLC)GN_zO;;sO>(d+6`CJc| zjdlyxSB}gESyS3J;pGI03bq&*FpdNtgf`*J)_%j4bIr^oI0iWjE6u?mvlw1aw( zwx7Et`ZTvA|2d@Lh6*u`jl_9c+sUSdlrz1*MT)&^gka4Uq{-ZRtUl|9A7Ce4td%qK zOnP)KoD81fgDol3euwkg=63VFwgl1AoD0QTa~fLAulHP?UoI(+T0`me4%eNW!~C1U z{HP+md)gM#I&vg%b}@VyK`FIA%20iE;q3>GN3Xr@(Cd|_>hrvNWCr(Xu(s3MY7=%Q z+$9)ZGf%mTMCaICmP7Z$Q_5PR&zHH+R;rafuswAz__Zq>1|2Tv!TMSwYEbN&816u$ z1k!r-T0We+oHLH5=Yn)NwyxKm4O~FQTP1|8lf?{%vv}#EHiz+PCQytdhKe4unA zhVko|TBQ#HUDbXIxsv4g+eFFc3j^h~1@w|nYG>C%jvxP9aeMP@>$ciL8B}>d$Ig?04wOwuT0P3} z3*4=lOScB8Hh;^YUY;oD@oa^*e82}$AZ@+&-5ON2zwv6`y46^Fv|@~>RGK>Pqcy0e zfR_36-RwH`LFn))*Rg%tnp{KJ<1<+_N6(%1r|b+{LHk$J<} zrZY1)I{j+IT}J@5z2)^)rk39i;NHxHv|!9|)~9V}##ukb<@E$my|Fsg&i1`XcHnk> z{R+z|Er62S>!(C!_sug&FF9&#M?2I}g7_a!oZUIITI^hR&pemZcJFNRNzVIbms9fA zpw@kI(H!OwY4GWrnaOKVxdC!fgC{|y*czY)Pb%dUp48AimGesOcUJF>YPltU4P8<_ zzm(877Yb}C?w@NJLP?GJwimjP^XKgE?^f%p)2a31W`&n7>PpF*$m>ga7ru<9HdL?u zuTwEYT)Z$5B#&}oTsH=Fw_J+KiS9~;KZtnzK0 zWj>5NpN_6X=R@F{mK0uFq8DKP!)cXr>vaYFh<`2U?&&KR z`ZM!Me|Zf7ZFpoZ^%>u2K)LheQ>I?lrw)WWkIsc!r>tv7FEwXE{^m}vQ&s@IKE35# zJqP)AD(x`vrC9F%o8A=4eO_AkNTY{?CqXLdMeS+umKx9oUvJK?4G(}Ceif0@Zts=6 zcP?_`EiZs>U+J@>n>)hhGhHs)efIxMIPWhrfPUY+GCTTthX`#0Lhk50@>bfo%j=#=f7M%4K$~aTi4Fy9nh*dNqwCgX1;!^k8|ax1l&45sOD<^ z{d##K61CnlpD~BSt)LV4`S0-o2 zlpvYwfp?PkV{yGeKiF91?fp6Re?7GXv~-rU*8qG(yzqppQ|fOh$2%KF6GUrSKCjJ}-vob0d9lpW9}AOGgFO^yY3E&9qS{jF}7W4m38b~&X7 zv}>00h+igxWH4whvn?H;_L|!`3#uugwS`l&Q=0WP*KMu@5o9;LP%I~6Zf&nsZ2%v9 zT6{i7shb{`&%{^f{Iy!w641_Bu378rZm$nYMy{{ExwX+-LqPlHRonVoZS=gf&1YrL ztZn6I%q!Ox(9T(|!u)kmOZl;m=9iW}HMj9uyQNNjZ+%;x+2E~dt5aVlXh|HGX?HIzGE^`&|CmZNVwW^S#hsPBAE&)L#mJ{Vlu+_!L>TU&x_3Xp_3@o)wQ z+k^P38iWrxbo*eh@3ozh~tno4)FT((%AML zlTtFpn*~%39;Ykqs^p&E+m-FVffOP4gOg{l{j#<45=M>~e3l`R3PVm5#!? z5762*Z!PC_rM!nk|FMVs2We~Pv1_}#{@V1RT|3|BySks=mVWxcPwxJarC(e1`M*#N z5oI+-EUUE%pmQ06VF}*fysT@V)fv%0YlvH+W1=mL=_=mQ6bV`3kUVu3KB<3;yL4>f zoc;SoGjetnUPeWs)@5CV3wU^=F`|~R>YIppiI}#ClE@{hDWbZH59!>+XYEqnY-q7s z@z;h-;U*Odhr`V+q0Tj(k;WDf32bY#Y5+Fe+S1tC8NvU}%Q_zowYIi^$R%otMPhHd zUK8^TR(sj%EPSg2#F=nUOGj7X$GZw|b{3vp*7=mh{9T1&SK)&Op6)6<*Ht)&rgs)T zN;(UF+p*ZPLehwv)q-|c9%)80ysT@=g=|GDQSuTM_EymD)YZ@o&NMHv!m6RG@Htjq zJdN7gnX~XbSoK^Rs(TTXJr`QK*b3dO@%SP3W)*5`XQGWQ9jv;m0GdySQ62Jj7Jdf* zBlsyhD6wZ;r6ao4Bt?%eQ4kB&S@;ZkLCRt;F*_nmF~Wv30)Jg-MunjHd6e3`*itKQ zRt@deO$*tY7rKg@yNb(K+{8kQXLLI{3$KTkpdE&Zu4W(#{T1#ie!3G}7P_RFFIhJ$ zY31oHEv@JeAqC*mp|Eb>^GsZN(gCz0gxK(6n~|jynm3-uPdWM9N)eP<3!(?vyRoGS z=ud&WpTjRZ1s#R|(ez(;I_h(pm59;ILO>c0Xn}*9TiPI3$p6pC|F8J{j{Yq+VQit= zB8E+|P5xg9W_A`k$>ic`U4bNKxf0O*^3Qg^NP&_}mw{wDAjwd^bf2zAI_`t$IFw%! zHbIhDGzk#3%TN#N(epx63n<%W3m?a?BYcg`UBxf7MM4lyvZTF5cN==W#Fyf7n=i%X zQqT(4Q`GQxSzGZ!YXlW6M?gq;r3Ixx{=!WHn=z1EwVEir+=l*ua>4)YR0HlQP+Mt+BkpF^db8Esj@G^k zrD%m$grUDf1P!f?$_h0g6vhyyy1b>Ot+Tibjl=()#T_Vyn)oXIw}Y>B61g7hA8oN{$jiojlk1wAmUYG zewP7^>dwMHT-O4Yuu>^O=VnnYs*xH#?5g)*_-!pvPLlX&SMezHzqhudrnaMKRV#!9 ziC?l>F)twSVyHEILjY?|iy12NY^dwDiKV85m!(4?Nr7R%ZRaaN> zdi+n4Fxlz=*?axZm~6tpPPW|7sMPcMYf#HUEPo~G0VO6wpY%s78^DVQ2lO@F94?5L_`c40_bc*89zo;KbL!2-EVgL=$FhQZl}F)3AsySy_TM{p-~ zV{xD{+*v%K>t9s%+!1Mnwpn5=2`!;U>MA~q6tqb$p-_$&t%-lyv=}PyHEA&ehIg-p zmOC^FF`m9bO7g~z=qesA<+De|(<^jmy0pBlb6&&PXaLFYg-#OJ$g_1#htDi_33PO(pX{NC6IA-A&oMX=zK7zXajO$6YPIYFd8PwBV{X zg`8(CMOVW&aON#h1chT06%OefuS(&cbj09ZBL??US+TDfFqN}SQaJ-*jwtZo{$Hk$ z(`+v03SgUBXrw~-6vxrFR+%RjFR>Ppk&hCif5dhTa~cST?`lDViU~3ctPxeLe?>dm zsMpYsHkN7-|FcTTw34m;ZddVF4Z_YsiRTbsjAxpYEL}|Tm6bH2B+$Yx;{|gSra4Yu z35#uliCA1}|1LJ%d4u|f!;pc+B5G5PL`nBwPwk?cMxyNgD=wD)!jB|cV9-l7dTIFj zAi1WPnv~b;l-HBC!WY2G4Kx?^;L&`hrLQY~0rDq79l@T^?0A6za{UFi=q1s#;V{Em z>xRQ0Xj#-%JkRFqyci5$!LP4*&I5%_^BVC2xp}iR#4-=tcoJ|DhYpN6y z#6AzhNHFyh@2YKi#j@HW4Ypnp&Mw7rBLqQ(qEQQU86u0}wst6eN@ciJuWZ8Ml0jEE ztp`11dLabhJ9mSx&auz6Y+wlqQCip&7Y==yOn(%9W#Wie{2&rO`n zMQl%(ezl>^@q`A^=H~D7{Kfx9%3&2#i9LNk+Cai2U16F~U z3m6FUP@+bQa^Z!8EijGWKtEEzF}A=X3>Nz#rF)~e(5C8hUB!h=CE~&0caQkHEp;`Z<$@gB|_>G5JH-G7#hd+DQ{ySTL^_|22q4VYTcP!;5!YJPHqB}=_hA*dX zCh`e9^12YpU3 zuc}6ce~lJFhyWTuHR7^R)ySB}RsahwjulOzX8hmU(A*gbHHUx*7zM=@=|UkX?3h7VThT!XZRAk&?ZCIu&CE7u|fAvn0K5L}a3=S1j#?2I4@ zQEQr!kWNcvTGPf=6kU|eV}+2K4%QGB;B;|>R>%+RUq-M*tMdtglkh-bihY*u8oDQ+ zTMUP!xEjvkVWA44e?P0c^EAC(p5cUf9)|k2!wNIgb7(#-zUScEfExueQ(VS!ip%M< zvIEa`Fsbb|0Qupr!prhgT*mbYmWZU}9Lim}jjm&Oi=Ku51`i0}k$w?*M1ZlyT}a9j zwW07yFqsJaEJAUM!}t#w7fZGVlrbIBg-)A7r*&20FDaZ8%Hfg~3Q#NwL6gpPz{WvA z(~Cok>C|YYf24IqQ-@iR!G70``5L@cXu~IAnV~Elxp2V2-*#e*UA2rJiJQe3(~vGJtJE>DMqp>URi z@fcyDuyoF=2x3X1d*$8|!G+hH;MFCO5bPXTHNIy5UM)q#w}NPtVmB)8#2jUf#S~oZ zu6Wo$sZx@{8%rWsxN{lXYA>Ww61oAHJpAjrMIg3=K42_4m}r4&EQLev2dtUVi?j>j ztkLNarYD&w`qL2ivK=Tcqv!yIOm?o7N>)SvvKHak|L9`z0HFtAJ{O+_0$gi_ zorNEi@VTWJTEMfG;zEq8qY%Uwu2anh>A^c?UDaik=Z-VClj>ELTwJ(NT48s>tCV_e z%W7x_%W3$kP-_xJys4Y_CPKQsZ;BZ30a@Q%!f}Jl?my`@)gEaeTR5oL5u(?~ElRh& z0A&aYxS662eN4f^KV9;7L5r+eE`em5UU2^s+&@5@eudy7QjB(XTS+d8OP%228&SS4 zp}5rk<+_t2>3Xaapaa`6Qh?zyty9astK;5=US(?C1Q{2X(02=kYLgCRLFBk+ak@-X+E@f7$2o`4WkC#C8GxQP;2NKE)Z#i?M5Emt~f2SB9_5I zks7m7vkNUQ!)_JC+OQGghf`=L2}JafR13HT;2$Ue!-m4Xv+A03185 z<4?;oII05}N%yjGMP=xNbw>KQC|gYTr0vVFn-BM=R!NAJnu<&H&-EA=WFy_8C;?#^ zBrsB;@z$wU{Dm6V;enVncnaeQZgzm17O#^Er6*;Zun7sVRYLeIAZ8(fFAHY6sg;;^ zX3{f=6TDv1y-`9ybDLy^tEFHu?gWoA2b6Fr*&9;CX+f(tqV)im5C(WDC5ENRR9wuU ztsW)+D*~?yd<~HDXi~#F&lbD^CfpXpGTfI*=knRf7^uxfGNX|^6GVB$gSUNTw3m9<*htr4}8si`u74D%rvoI^{;)HI4hx znuUXj@n|}qjP1h%Zlwd`8pUF^P!Jy2ht>%T2Vm?N1&u0IFsAWfG=H>N_kmKkTI!i& z3R#9i3wu+k%<+AbseE!Gg{$;JZ3F3}iEI*0V6weS>q^EdYL&LkQs29dCVqJx6w_Ln zLCW|3Lr^lSytD;%kOGkhYw!;=?ZA(pre_gfiza0LyJlZzU<=sEEGrUNHq(zStoLEj z*7G2W)w?>QysIoEE36Bm(#MjBU0RL4CfT*xOxo(`u3Ib>IT)q3$S1Pzh@7ONxGnv} zQ;~HiIm{SDyLVaYozB=COk|%-#u7+vhfK=*BKs2gqnUW_{*!i~r!O;^&a)Jy-f5|K z4Cb?m=y)nH~GdR^hWEpyEPqs~7NB!SN@_m@MS(#^h1zL%eP1S(O2jy0ckD_=$I_V`W&y~@?K;^) zEu$D{6pHIhPp;{!H#>&(9dHVwSj-F1MV9JdSpM}j-SD!q_8nxUr}3A%BcxJq;9WO; z?gM-NZr7boTYrS%h^sNK;6Yb9T(#Mk$?i&}_C=FvHJ*!QvWY}bJcXGV|Gsw%$|z@x ztEBID&=TUVhmP@5qUS{zUp_q3J%GP=?+B?kM2v`02;*q8dKfzy!+`xbygZ1*o(J$% zp<(>)#}35-N%y;r|MTBC)9F8=7>4>52m=MbPA_QWF8o+1m3Q{;#*PP%#PgWtD7^ao zw?=XeA(jW;b8_%Kk96Fi(Eon5aW81K?0uFb@M8fbt&=pHl=<%t+<^feV5emr@|s;2 z)-i<^>F*@6{2*_BxyQfy&V+MwD@rPhzm5WTLa28y_`(mvr=({l&?n^3 z7;a3=BTWQ<1)=YNjc2bjwc#tD_{zn6_n$+jmK)yq$2<7+?%uVOn@tMNHRY|ZyceB5 oR5*Cg{`P+jvvMBx{}2EDyXL^AkmAy4;?959t@t7Fv*f`42Z+9z*8l(j literal 139776 zcmce<2Ygh;`Zqpv&gN`MA$51tNPr}qWH*6OL+GJfK|nx7ihzLV;#oi?CI&&&D~Kp! zZzy&V>|j@HSW&Fkf?lszul*<9YsLTfd1iL^1hD-6@B4Z812glT=b2}odFGjN=9CD-; zg$Nr$_*Cu_eUL6kdI(}6vN??;=}o^xEZUICECTJCeipIPzf`OtW#P9Fau25jJ%6Wc70Nnj zGwh=))&huNcO@(JFzf(yiiZ)@^sxPi3O`a8 ziXDku8>C3TFS%kHV>msh|KJ2I#fN0YJ$H$Zb6Q zx8HtyKP%VV8-!mM$1n>7-mMW5ZfA($;(=cTvV|CFI2a`hop}gi{lEj`(Oggm8ir#| zd^!XNEKkeH(9*Q_S~Gy-jbOAfwMJ~riIH@}o5oe6Y;kvw*ov|kxjCk%gRo~prHov| zJ_@n@6N1X-fhZkl#_Sw0tbIAo1V?&oFld>PLVs)s5_v8$IUf5MaQI_bBLcM_ydUsK z0l016*id3li&W>N#hQ?;Y#v4#R`YO*ys4UUELiwxhyf$ZdFlO(oV2JHP+JMTS3-6g zEGlP-0GfmJ64B>&wFSvT8;^nmVH!e_5hUG{>j~N;DV3Is`3{MqIxEYQKQ34k9}N^Z zAm12W)INw3R-|{XWgkpQZ?4xq1PSFw=;mlqjxTm7k^DLSXeM`QO&rJ_QM}x zdvrjKy#xvej2OBtK<)%D2&6ac1QjC}V<13F(Xoj0$R5-Id7d0k6yqmUmllFom_Zt; zjn_~K)5cNNJsqgFBhdOJ>IHOr5*-woZ^c@nL8ZGE>Y#hpnbK>+B7r<#uFrOmSd4L`rp$UwnJ{QT`H1srq8FlJ!=}00(z4=< zz(ghspcc4Cpmr_PI0cEu6JffVgN*p804>xgZA98r*wn@z#_1H>r-1?cbq1!#UP`c! zhITWdr6^KO5P`?g= z5i?=$`01!LU^x?VFdw%dU1d3^Cewyx9}f#e{Z?5y`6H-hEjkgaB6Ud?>_U@!j_I@| zOPU6a4l8yB6*8U6-Gu2b!aHsP9FMlNdxPkGgXJrgOea4#p&kUo1GV5#O&!)wIE)p< zwLw(}VUk-U_Oj?a{@HC%LfI|049W89i4!*-rE|$`o9q`m zi?VBuH5Ye*n$b+d+(-#kv)aF#0wZeQx=rr6*h-X+j&jv*atEsXZg#4Allw6ScMn8E zcB+1pyEAqU@^QIvxwiB;_}p}~eOwy*p0$i@n1xKT*0>r6o!=eG!>#HmN^8NMBH^ZW zuT)Y4&LxTP7UE;~;RG_M1ZQvp8B~@tI8oHvlQ3Tc4MD5jepQ$3xb}V(!%+D%zrvUn z9pG2?-=LW39FY`-CS!0bSE+#J?Of#~HycJeU19AFV(iOyY&W~v;KA)Y3gePJ>M+Bs z%QT`s!z4$vVD7{^k@T(epqmlHq+`WaA*r2cHRZA)W9K88aH2JwO;(Iu;L2{}Y_g^D zL`(_hV(JoAEA5YF!xr>|LetFXQL09h>$TUSI6NvSbbkn+3PsY*@m$=F4dAJQI3 zwVK?a?19|Gjz%2g)~ea0rZGdwQ~sl5C?`_o*pq7J=uVjcry{E#0Y4wMhoUvPkbG;OSev^v>NHu)wFg-`{sBS*oaM!)2`am5>#?3c;ThbxQKE)xhuwu#lXzR8j16p`Pu< zekyv*e)vZcLcbSc^Z+@H9aL1QVJoZb_@2*e(ag`?%Ry*q>>w`f(+D^5xbs} znaWn7)dN&rnH%i8!Izii&B=_tNhP?hOjli5uDUW(b!DKg487BDh1a+pZ8ml84XCfO zjVQK{_O*TlxZWv2#o~22-ZnCLyo#a5_;o7%hT)8bEloZyaV8+iICc{xIgJ;0k!?YfItBL!B_h@r;0;-F*p#dv8+=@K_a&&;9E?kBAovo74U{8r+ba_=k@qEHYa&FD?pFYIcSadmL<)wPsbY#(n}x+Q>hNn9m#O>|&1;bPk#m-;P}D2QP<7xK>=o z(gbHeh5XtQ%jsJn7V13bP^8(JnbUG6D%y1LJ99&B8cNKf(dQtjO}CsAinMsk`LskQ zUDHQ;WU7}Zj|{7HHM$t~asE{&7H+5v`P7v04+z>&8Fq$tquj!FxkXN&?vz{Xv!7wM z66bu%ph2%qsmA#g?+3h5%d1AY<-7tWZi#Dh$!x%cEBtD9@mOW)33ZD5usWE~d0I*6 zvzoIDk^MHc_bPNtOwo#*olGlkU!=s@(U&BZ9-v4^=M|=v`Ed@Rno<^UhBUNmi<%!B zr_k|>>v+O))`4&TE`;%a?Uyiq46YKWQFGSWV%|52vxgkH=}{R#!$sn9(81NpMQ9PC zbt+nq$U~ErRWs6zZA9$IMlG0p+>_k1v~!_On)mnpNHc8cuZ3ZUk42qMZc>hzt(lTd zA>S|VZi$}|7ty#<8s!gQZ=FusH6oqzR+GBaYF(O`*-t}auXPg5rm!?-cB0sr!y~ch zfCG^;tk@1BG(V3py-HP3oN$LXAspW6jnzN`Pv)@~z*k#l(i&yiFA~UAfM+pYnImb= z{DD+3tO~-Dy|D-+Y^W@977!)nvljbo;}Y&?x?Q5&RyWiEGj}!&q0ZdKiSs{D{pr4_ zr?HN`i70lB^<=lTGx48{^>wHa{A}6YgW6m6C9+V%)#wUu>}8}gtg;RXL%jfA9>%@6 znPDeuFlAr__t5Qb0cf%?hd(bM7s{Lv0t=I8y$iWdp7K2dAzP0sq1f77uP$%fPy=6yNc z6NcfQFcjEt!cg*g3fZ?3Jxv_4&orTH&YhU_IP?xW&kz&Ekc$)Z{s-d0%atF~x%zyx zyEN6mk0;6+G3YBbVrjtI|?S#5#b{?Q-3c%QY?kW*I z58rq0!m&edbPOF(VDrRrUmf?N`0B*PY74R9oP)S<&OuBDZ);kZuZPi0ag3Kf_^~?U z?3kPnapr{%#}K)enic7+HX>F$jyBPz>{bvFVGB&rZHUw~Qu{``-Gr8}=Hh%&*QDCh z!*s8bw7>RHH1ahoN!mWb~ljXMqLxR=x^CoNQ08ENvyR)Z4#QpMrA zk9mKQ=ZOqFndnHE(#OGEq$Pg9rvHqaS(%vd@F@P`#}cVIDCl1hbd%zoz&cpnUPy~22|9uJCa1Q<{Lh5qAT}5t-g`FQsBrPiY8*{_!@W#&ec2fJjWVg`LJRi zz{3L#13|H3yJ^gLW0z9j^BO{TuDx{UIuNPibs{s;ORodOwC^&J840?msZ}D=pJ7I` zwNgt-sSi<;!pS*Q8`2xQjH*u@o2&pguMC$Umo9$K;S5Zlq<~&HN}N@cn=-=zYEyD; zJawrSspxdA&jl!2tY zOhi_{GgBA_w_IwRpw;+0>MKbumab|-`zeJp0hdxx!^MrI)1_3gTdBy=x~i*B`M=*{ zz4$)xYx~7l)u@M2yLI?*c-(aSPp!jVQ704rNn_dh33}?~j{TMAoU5q=l+$95@+VH4 z&HIMT$Y|%m)5OBe$PjiGbqP99Ob#_CYQ&en_OK8Z&pkt?*7syE!uB|WaE6(oEqEe zTB1sPnU}am^9o#s(D^*B!I^#J>FsTq8vBu1df;o$sjVsR`2W|klsoRb+}EyazpL4& zC8`~r#KN`8EfQypdELEYDcVE76%!uz>^*s@X-pkD|IJNll`!Nz%AJ%4)w=@s7NkFFDOOb8mw%u z!5JwHh~m~D>{PY!4CpR?cKhOOsp3R&7cX)(AcDIZq@!!r#>OxT@d0N6!XiEU7;e|Z zRZOZoDj z+xtsxiSr6sT{)>EmSGDCm%_;?MrAuk>RH>a%butC4)YQ{e?}9AW2K5-g`#dB`CEHi zEKk{jC@EWHIAI9!IrB+WS7;GnDd_j4KdU+Ny!HZDkU%v@5+yZ9;=qS>qlMbb?#CAu z>CQ>0!Rwrvs3+Z7hot4~No08Wek+C<@1qAGrg6qxE+Zm z%@fKXt*aBNW227g{cKYG6CUtHu{$INysFzP;B5Rm@DOf2zrDC~QsRh`5{KEp{pf97 z)4t@nsggu-mvlQQ-%C6}>tw{9B`=_DYwTZWL#V!+E6aHRHsBi!bPqGh8H#-hRvSxF z0FNc5@*`LtTulE4-Fb+tNbX2y944O7RX@#$HJ7d`>E=YFz?GLei8N>%rcMVqGj%H) z?eOy&PZFISsKnx<*Qu`C@W5ni%7d!2NG-H-@s5!!9)r)>mH=ttb@QxXPY<-;dqFShw8YA;tP{! zoWzDRPU6BDCo$0@g3QF@3UiUD;`!(c*w@~JzQSyB6w;Ov!?qPKRN#=_iob+FjfV`e z4rMSkz*&ePy1-Dkz{|oEtGnP|fe^4-*P=e&NL_%$UTYOO_}3s+wh@KiWQo+)T6QjC zy3_nWAeHvaLh3uD)Z+#<^ii#)+I8yi3;m75rq!c%!lasP>OpP zH1An<9@<*-gkjTlKyA8n6PgqM9vb2m3K~oX?U5`yA6$n0PfEhZ7QGsE5Tq31=|xm< zm==6E#hr~p8p&2ol~IES06X)f8wm|8%p`TBs^mjM{2PV8&ug@vYLRo_n%Yo_pFMJGvwkxg>;L`5j&P zkeuwJgeu26KckBdT%fj#T2Z(Zp0T-|{2ND}0eXo{Z5ku_Wl<$H_5%o^De)f>rIuG- z3~LNpQ?<5yrQrNVZf<{w+)#Jj#ttNjbF>h16{cn=9H=>}Y;XJyR9No(w*lZDEKDXJH)6k1k}EZ0dx?Ca5km(B zqUp|iRKJ=ZVnWg>$=x96ho8!($0YJ%1`|w#t+@73GcFFOFyr2ecE@o?05dL8=mok6 zy_gpF}L#smM^{+JK4GW;<=qV!Ney$V2&`}eyNX7TZZSNb&!1=Q3ZN#h6I^3r@{ObhQV zd13*GXvH}#8ktv>zt^G#E1r(b$~MZi!-)pwd42qzL2=JQysbnbJC;PIq9lZIsVXOJjM9&pS8lL z9wFfxKyvxb8_Rg@2H3K%%1e9o=y9HlXw4W z@b*+wy~*oD&q_6;m@%4H_%2Ko??wEJ%TUN!c&O_>mrOI(0SX!PzFEMA`vju&ETFk) zAm(TrE@;&>(UXGtSU>Qn4QJ3(^_cJY8EEALQRs?g1@CH-f=VZ)i>f}J4e9*sK30ul ze$^D?!=$xBM5r7F;bU-GyxL`Bq*#dHlveyTO2;0hWDX>7ndK;h`f}p0aRIaCMRsF!Lik&ymlk`kJp8WMx8|$wX z9Ro30p4JAa=sA#zrb|UndleOBLqf$gJf*Xbiu9%$>u3t{&F;`K{syY1{m(0?5x%*T zqGk$X4}t>Ud=pW;lzOV1T<$rLT)z1-Q9FWK*+vw*6S-VxV%*W5@fBh$V@9IbU5K#) zfwI|?h7k4S8!2N2lvAXa9hc$NenEE1^H?drI5N@IwYYQatZRo-PGL7-HW0xK?N<$$ zVSuc5zR`dOb8wAH+unW{Wk{wxN7aYdQk^$kHCRsF1=`VSM}xK^i6%9i1qq>cHMqoO zwv$cOgc1%qHvD^q;JrNye~$(B%`iF0kO!gvc9Ix9cl!;ukV~ zwRu>jFo>7*S$rSPX}hUz@N!k#0%b|t(kIxwwuz`kNbiShoYZN_Ny_|%?CSw*Ft>1c+_ zOkRtofs5gt7++5qv2yr%>+`7AHBxrc0O-U6fG9RD7bA51L(jUWiDTg~^fUN~Hab?t zp}I!4wKEI#8Lcn0m-s44?9390Vq=X`nN#}8Js`{$>0o5AcKT)1}88#rU_h= zi5?i|hI2le6zc-*@$f^V;XILmc)~qmIA0}ThA&!TIME9=Gxlqlrsehd;{bQ1_-A%v- zFiH52n~<3#s8;~7%J2Ka7S?n9!WQjAPE=|MdTJk=ZETF&y{}aPdm7EuL$OLE6Yp!O zZ0e^2WK(Y)Ae;J3W%FxXL&!H-7uebqFf0G?9@i;m6pKG;Vsfb7UD$hAHSZ@5Jh&d^*-Ex@ZzWIpxRTMr z9{D%jne@&f^&P!)NL_^$7@tp}L`{+XHr4QNRfDOXe>P3riJ(`(vZd*IoYB_`t91M^W1Z9wwJ@nyNmOG4{gVB%@wO(gbOAEG+GMz3rmO6p2IVDfEQ zbDtSFig}1;UY;WC>F|o^v2O8iw-^6WN<2|g;?q4&$whR)ojh3|m&SLm^`SUzgvK?j zLZ`DuV%QO&ziES(YsBz`QXpF5@u{;2B?9YO03rm=%g03~c}iB#!R1zE&}b&B&`iz= zWl%4#J20w#irg&G_ah6PHYkPL)tLK>S+2Tmo)GLAo4?nDiPPZ;QIvh#$aHn1)uzwe3IwW&!J(j1Ns$qGRm*e5%8-oQXNl}RL2L* z=%W3cYUX}UHP-D^AGDYKWlAudfB+aLFJV#UU4dJIfUC!#Wk;w|Tr$y_4-N1b`XJDVQw^*Ru}_c@?cO~sGZbzm1trC>U>%U2cM2u{kzl`Os~GmKPCQ=fXl1K?k) zBBT}_KEd+0}y;xITogeW%7J0dm? z9U}4JpwuLv=@|qo91WA>;g{qyJ@DY!C_`fmYZb@G>v%53w12$;<>;4mYbt>eK?Mv? zEA9{}fBhDTy_RJ_8*~!1AqsslDPrTYJ7Tte*Phc$oPC*-DD=Igh>eYM#KtTaX(2s~ zv{sxZy2bmbPy-htij9RJV#A9gEv#=7KSt!tK=;J^foo|Wqj;uKRy=FEG1;6^Q|DYo zl%HULrSw^ac~pm|WjI3f0$B|e3@pn3=!~T8X?s{+jdQud&a|faL0YBD(!`~#K__9RhC~+7FeBcM074uCz zrI*@}j|Y`buv}kII1*XB{iJn>HWl>K`*Do_cKh)*7}sbfL&cUMnb?o3Y%*87>_&8w zvRtfR>jWwL@k27d*?r0*)E-b!4$zotg>5{Of(($^MG0m2wNmFk#dG!s;BKpV}J zHzoEM)PW`^k|w7SSE5awO;3CnHL@R=BwwGxj_zr1r7&Y^DP zJBu!2O-Duf3z;LG+xDw@CDn{;la#ssu;wFOHPdZlzU)YRME8LSW>I6Nqp9wk|3Tw>RQ5hG;)1ufj#=7&%O2YtSlZAcg) z&J6|LTbAPS*}E~7^g9be@V??lNGslOf|rh167m#7F!pbneQ0am@+iqI`<0m^)kZU6 z-l*fn8YQSOAqY2OMS@i`7D7br4rM$epN0ACPawPsy3jV)UCA#jr~yMo7_N$19wQZu zW{OmeMTr_Q)=;A=r#alZKhC=UtaP`HX2SX+!^qLHinXlw#~EdcQ}eOv&#NAW>MSc? z>7tB442|RQ*tY6^-MnDneSBV9E7TOlM_?c-fGX zCo&h`1SAgnD5@Dthpsk8fE6v}51Qg0DjidDR&BuRj~xuwsz^`brBiCfTan=PC$egD zz>D2kpw@?PJaHk^b0}r3fl8EUoB@xB??8!4uiXcOIQ9soEtP(V(q?QMB6V+h2pW@# zHYdKr_coTr1McsiK#@P$-=6?k^wax$@8t^-H7$vz#! zq)FEXDxb75*|k-E$WEzavWL@!Nb=g?IkL|CiDirH;Q@p1tWk4YC_tK|worgHHLQh) z3cfNq39=aI^|3Dg0wlIQ4W8th8N~A(ChZE}q)GN42x^j9yOLR0Szjg+c9G9>tRu2V3bE_DJKX6!ihD1S({FFE~D$i%nT4#KxJ zapi)~Zsz#7Ol^ae?&boxedgr73X%gD_L z*)xdBjmhK&+H2lHY2IOf&F^WixtHum z_dlvZ;7fCug!`=Yx;F z->?z!0Pa7Wa{W&K#b-iVdN9#{^eNS3|7AwT_*L)WQIcfurR7@qTCjx9Q6KdJF8%`e zI3IcsmovKeyvhdNqz&+p7tD_}4H@eIO0Y4)? zi+YUD%$zMW9nEH(cLlbd$0N}Aal)Z1llUwoozGMF_^W`QL!kM)T@8E@0*%wJ0X_qP z#=dKT=OfVgW5P#Xm&6|+=?vYF#9NVc%C1l1bCGnON#VXX0H20H%lndW@x~-R1xYu) zX&?OdJ~;En_WZ;4!Oi>Nd-uWL60W`}S^pX&-T1kEaN5o7>BIKH%lE-g?SuWdxXZV^ z2A4^GR^B-r#0~T{$UqC`C~P}(_02CusSG(=hy(9i{GH=MC+$|g%jI;EmdTDv|EYP>BrZJeA0F9#n}e=N~H3!O6LuOJzGlRU*e} zp@dTPbyl?~p{i0bq*V-S6$`bBMOwvTtzwB*u~e(rF`=P9p|3a zo)W6b7_o^%&Z5>=0q7Ez`jTSmI*Q3I6caN}U*4iMih1keyD5#8iRg)IJhez2#V-Qv zdk0V5v+FNn)N$R;Tbkk#zds zm84&cr1N#buLDK2_OcLLOq?7k-60bqh`89=`p9B63fv*4f9l#$V(0Kmyz`GD=%yao+ zFC;O~{o7NR=l;eQlXPBd9#3IjYa%Zt>AbdVOkrMIieFCBd2QH`!n`(QzmlY%iKO#J z3J=-|ya9pMm)Dx2SCjZmB%Mtu%xjDFT9VFdiwpDG;=;VPxG=9RF3f9-3-j9I!o0S) zFt07sQ}y%O;=;VPxG=9RF3f9-3-j9I!o0S)Ft061-12wKFGg9f#JsHL`H-Gg!+I%6 z&C6;@Ni892X(`q7bjQS;>(>)DmJq$Dq$g(KjKtiX>1;=5`~#N6##LiD1N zo0zimoQ}KnynL)m6gZcwM9|r-5+SGJb>;~>b5)|yxmhKOoKIDv*sD+CS(T`Aeo=|8&hWRmxb2*y z64i-irY5n>L=wwP)Y+_fYMrlCqAsz_baSF_vz+eET$QMIu2hL0i4~})^9JRp73f{+ zT(xu*wPM%ID-HEHtvE!amE{vGGs(Cv{tsGpn71zeIi=szd^7391=m1)ne;m=5XA1* z;yNw#;3HK+>AA_|&pEZC7WcjRJz$K_qs?p^QEZ&h zL~5|jUx$1fw{viXdQl>&?!?pm{%N!j;%BPwj9v|n)_=Aa{2%1ecVQuzD0U+RoAfa$ zs}(13ZWaEU;v@=ls;Z#J6^Y7Ceqo$d`U}L)W{6J_=^B*m8gGOg*I_MA7-1|vto;H> z+W*seEpGDa^IBrSdF?M#LVY||xMwMjUVp*SYdCrIx)%a*^!h7B`kJXs7@ZPlt$Cur zPMo#keyc~NQ`IM3 z3`|##Jzq!JssP`*S7(}EQ&Ak8QrXDyMl)ePe58-aQNJp-Zf5m7r$Orl*ULBHiQ%0euC_$SatfDpqHt>&g>P^;m2(d3NI55!Qutsg$vL_6H2jsF zrbY_?TT0;@r6=~b#CJuMK0A%611NmGocLe2C|$y(Mwc2@mgwEls0xT%%UAafi2rt@ zaLy14e?Vx7y=kxbmWv(T=%i>bYGhJl01%|FAED{vSbdu1K>E3I@b2 z1w`#$P1Nrp!4l6P42a*r9}rCgSNFc2Wd=kyn|MCAh&m^asF$X8|o-LcqoORrmgP%o7Q{`YyJUp(xqz4Ekmg- z=W;C%L`dd&Hq~;ym%>@BZ3}DCg(c5Ki!5LK_33axmr0?s!9wfOwbN7-xBw5jf>DmOZ4kUJ~O$7(oP!5 zf1Yhp#&&*~d--;I>tIX#Pvqh1fY=oznK>Z}Z)~9OL=OMM`FC-64(Ie{o<5u|QGl6a38*Hz7?eUEMoNoS%1b6xt3X zofk6a-Q1!=SdT{IKn{7v!IXMV>FVA?F=jDRfx2UC5~4XGTXaER5yHR++J(_O6qGbZ z4`Vb91;r9R&}PA|<1hnw8CAk|L`&2i(wO3cfemooQ<{O`!=I)iZ4^OX)!G9-v&$vJ=t1 z4)g>m&`6DXF&bE|XuTQT+)<%EjJ{@+O?Nv{ZV{Kurh8F9C5&?Dq#5WuM!7UM0(EAT zFPaz`8VzH#mQew{#Uhh^aYsE<{<>&?~*BxjX%I#&Dy~LSp z-JN}I>pcZe7q4J+mqzC>YOpS z9IX}E!q(_QM&mTPl+jv^E@wSUhp2KJ82!Ms25~c^H#EAN+wf7JmOfL^Lyt15=&R6n zMjnlxX3frs3_>S2h-aDhPQO8DZG(7@W&R4<6#N~#9gJSCCNxa!WYosA5n>mkJVv9$ zn~XLvItcGNQXf^;Q@L^CC$@aNXi)D`i7|j~$QDg~h&Bm`tn_Xz>2kCvVl=I%LZ!@k z4QNw9>%{00M#qRs<}8j9=P~$h56OIzYd=Or8NJJBn&{4GCOD^v<3wLZy;-waqCcZw zxqY+65V;&)u(DRbbLNQ=j7Gz~35{$=8->5moGtFdtUDggCT_&}JaA=Sa58y+rGju+n|Z2`^wPJs@sl zOXM);R&fWnD0e8;@Pv54Rqko=Jaf`B3RA?3;x$If)~|>+xZLTi*{k9$SGhOwgfsP+ zqP-*j;iA1K{>`*%u5Y*a%0>G~e9JX_jcbf4;@{XBrrPi=E)1$feXj>{tHk+T9zqzd zel)j}IJgUin{uB(_^Y47y@4n$Tw1fDRwwaXI)xV^lwxSs)44~s^=*t=N4EXkK=}o^ z&w)RZ`82{T4!7h`jytU+sGP5IRjC&tXGedM6Bc*WictP3oSxrAX&-a` zlXDhUP|ox!3STOuaAcUmW`v!@%h@}j!_1){Alil=fvLC&Q)pXXZEk-kTv z!>JYDAY6g4lW6Hc;oWFsCvhf9)r%8zKSz34-S-HOWjPCTenR?)Tu)vf5iQ9=_*gN8 zpK_SaIp_AHoVIET`&4G-brK=2-J6kz^gOoG!I`AhWgWuE8I|1`VLzsR(IM(e_d)u& z4nq)5EE<7OwM9wmo_i2-p2?)X+r?!UAxyOE%cco=N47oOg~B^He38TNqZ3f7YlkTa zcLXRjIDM<1(wF6vR(G%x=6MKj6&E91V_chOi2>EOG0$eE-ixq@cnbM5hrWie6Zh|u zy0=iv{EA0&N!okhiOY|;)b~h#j&xAm@A(KkTLM2J9M$1Bgctig`6^AN{P{ubS+epe z9YVT?C_#8Dhucg_H%bZzc_@r?`V^1i?~0rrB8u=<4!4<6meYWoXXQZDQkp?_9>X@Q zP>>pswTo`j*2ZIegAf{iry9kLNz-{Gvmjyn3O`NQPFN8}&b)~%94PXUD+8Y#TBp28{qBk~iT(;J?4WZQQfo@Y~fbJGae^M|gJ zxQ(;W#>vLKd`nafI3iz)silwRO7ZxhygVs}pcR-mx;&k0iPJdj)tmCmtR>)_>!tL4 z-X*X=-<&pt71?JYOylsm4r^HcWstwkyc*#s>lTDrY4;%9U_FX(jj;pam&Ti@{d@ak zgbSNKL)hy5s$EXK_&D$*B)^-r7vb62-hxhI28SCFQjd2iAV0}Rc)usVV1It%DFd~U zc?N-pJiG$oogL~}LIbF0S_2Wr<>3fNduJegnZr{&aipt_vk-poxuoDgR{E+0y(2zD zn6OVbScdAo0i`<0TM$-y?m;-udbD6{IhJ6tG90d_UH;^DXnGR;9W|YrM7x2`P9mbM zPogwP*+@u|%uhgjl4;9;(r`ua0;Bc5zJtFg@Q7U+W#kchmyld9h7SG~=u3@yei19cFE z3i+Z{or2jSN(ikTQBehS3DZ>n<%(;PC>wv_Y?DI1XAABWdE!2eM&hp$0E!4jNH8tmg{xXzV1)k|-OTb()iUr8Cz5gmt^)ugi|mG?Ljx9Gav_povL@ zYj&|PiADu0#7bRm&Cok>&3(Q`;~NhPR*CgVPKoQuYZ-kakLWT!*j4PD>b@#$Y;S3;(U#^5BVDC5{=Rteh7{f*JzZ}uoviNMo$Zx3r2}O zjFyRDKW}K1ScI!E%mu#RnzBNpMVm(70Uab(F;X+iA>u2IXy!Xa`0A(}%{}4Jp<*$k zm16RMve04TN`+vvZlNQ@Rz}8TLg zCAD_4c$yKlc0y>1cvYkCfQ}ZQGE%LbDh|T&4$bA%+Nol)LTK%=p<~5!8cFd(aGKc3 zXa!n3J2XxF%7`qnAT(Wsa4ZDh4R@>`opzjvGFmSNm!29rPL$&yi2QnE=x%Ymn9OLs z__1(JXr5T1(Ib^thZcxk8kJYy96CvOa3xN&cX{=e&_dB&qaC4bAxA7sqQ^sV@sUQW z3!V)v5_^*9#n56w57?5F^q#MUmWcTp%^CRj(5YgDMz`nvGqjZ0@OwJV%KIYJEFRD_ zEAKy{7O@LQRBAj(afW!8(I=8P&k#Q{S}TqZitsX#f$Mu}?R`xmyj-+tbWWWJpCvBk zBm1=iLnC~)xSWw%bIuhvFj|jC{sQ511%_F&zVk!|BURsdqMDJaZ?zbp5!JUwysgo@ zb%o)z;tP#pwT0me1^&buYu2fMVfZ330oV7WC+V_I9LY%OvR)jkknc?R;CeAfqsRJ| zhu4dfG|KBA0a~Kbgt|UJtqQ?I1_0ftka&IYo%q{9_b{UNjSF8UDu$@qcSWa%uMoX7 zIzBi*e3e+MQE>45@HJw)M&*t3!`F!gLshxPqDA5Bao()Z*!o4`8$_f@q0fLeiXj?x z=&>k#qquUIqWxI1D14KcJc5vF?ag93Bhsune6x6q(OR)9`nT|{;!}-|53UQ}E=G)0 zQi6lmg*S;)HOg#U7v3yJj8e2;dR!g8OH9^iZ2i^YyTxM~tsZc7_#UxhwBi&!HiqvN z6$dNy-$7T0?-vUXQRp8)4~T|C2`N3diXn{F3t#CS;jQ9XjXo*3BfL%QK8!fmi(Nnu ziXRSFC@pwT_#x4KoI)=Rx+naIz~4J#&Z%7<3qK}q*XYvVW8ufekRufBvBDR^I49BQ zrtk~lCy9XH)0vkPy%ydseB%kJ@xEO&O(3+=Hx_gGc5#qK!#1HyY?YO`}z9 zr}(Ev)b^d?OO0kU9#yzge6P`x#+jfQM{*m);F{OMJ4H{0e780cZIDJ!RXhbWQlkwe z#Ce!TCt=63Q%ut6>|#PQH2ScJq@1GBS$MKwr#Mri>SB_ziVCoB)sXr1rI zqOhFIXuarNdS_9gyoZt6T@*|8qO{sw6w6a)lb*D@*j7{`muvJLP)B(wBelCImpOBY zQ}tN6ELRABhcd{Jk)g%Ry8b^?9Ih;|om6?Ks$gXW&=dwx;WHG$GT_x+Cx zUDxz$QB8uDd3w}ej3)tfxx;$qxlmO*^b(_tj$}5<4>heCGfJcUOw*`_Mj2SZ zZSYeKjWUN3wV_LKqwJ$;BxR5s#OOo+Fq9i4M`&~#$_qiCsf^Z&!9DvI50&pH(U{^U`Aw2@Qt>eP!%1vU->g2fi}AQnOrfjl7XtY-dZ1r< zc(}~gh;}T)WmqA!p&6XdGFmSls~Md(O1`a8ZP6vgqvXFdS_#@1`CYQyRmEdu_Cl&p zjnqSA38R(1A7JZ4WQ9g0*s~uZYc-YFCbIMtvyr^$3i z%f))rDw!s8HJT`LOQy>r7v~JwS<@c1tdbeByNfncHfUOf`E~J3IVnjiDLGE6Cw@MW zwWXN$ zj;vs`T;z*Aen<9kamHnni!&|{(wzOp_>#ChUZcB#7Rf~#J!y_FSu9W2Xo?(PvP7P% z(Nxd)l2hbbjZO#cRC%>VZJs^;)8uAGO3$V8Ax5gFm&)y$^E7c($x`{DM(+TfF8{01 zzs;jcTIFwyl$17^zBuJCZ8DG1a`CF1S<)u^DVi@T6wHS|LsC(wni7&gcfKNt|AoI=-(BDmTDBJB(zMUt^*03 z!$|eYS~>g_(ky|-GEzOgR!(NLT+B2cN4e=P+J$nirVTZBlw2s6Bxz~lB6$I$4`mTX z>N*)cm1_7<-Y|G3Q1_*TmWdkN7hNY0(Wuc&Xs$+&GdhdWhyL!(P2IQS#qfiYc#9JH$a^r;UFi+7mJzKMy?|yjQoXrRp2|q|^hUX&9c>k(m%f(q< zr}TEYjFIBJL$1=aX7jYtJLK49#7WmjQf!jnuOPJEH?rW&(oOOgMxXd;SGh@g&LY|; ze%e)Tk{KG&u5y#i*NAqNn`8+iWr+J2V|F;X?$ zCGkfn@LMjn$g5HAV2#eRZZExC&eiBz&$iNgyD` z_sgJ0dp#eQJ|Md=qWaRrRyl-`nl-k`OEscdW1D>Fe3GJOjcxKRjcC@`CckH-=80|c zSA}?<*d{$|sN9EsnkTl&422}k6A#M6HKKXqAvuYWvi!sHI7Z4656cr6Ef*2_W$D8* zu2DD7p3+BTvqo|2=TdrVSc*fsWM>Am6T&avPYa&Pfu1p z?<4-x>M7jPm3XMsfolAwkfT%5kTq zxP!;F3fFTf6?QBln^2FNq6+haM-1XwqKtiM3y%eAg&~xcZesqx=2olORr&m>7!iiJna4#covC-qfT$k$80Ax1ioLLd@IzgdNgcA3A!u7?tM@{Li2)p5}1xmk-u($Y-)3+ET|8ayzi?@0mH>J-Ij^ZjAyXx|CagvX1M+`Tw74tP9{CI zQO#k!Ij{fSVhcY_w}qePpd8%u1m|w?xD3~SD!vsL_5DiBLJp;`sopDo#PcSNvY+{W z(-8Tih*nRL3s7TBE@Dki7lqb3dAg|fUMh#0r&L`juag~m-6mJCgfV7#;A7w<%~y#? za5w(OCrKV-jv4T)9A}>1)XBJ#C0xl8Zs4}u&XVup^h2E9&OFP7j_blYpZ%cV}1=X72qu9MF+<(SLlHLxTi+HptChASxDKz(RU0YbU%Vc^#zsDmiE_@ja%bfOo}uQwkw-lB#)7IBJ=aN3 z@oS#bQP*y~VM;QiEVG2e1+2r5f}X1Sk)NjeQP5LVThZh2L)nz~1=3A<-*G6?ddZ&# zWFcH#5KbGw=>eP`>Qt?uFBu?x0dQoWm`0Ww0Ub7IRI-=(Iza^AP5o!08E`K8DlB zaC(dUu4#7K1TK3FhqG9p1?-255O%h}q@mvjBtFG}*Xdg?E0ktBcH&h4EgslAKj zW^Zq6fs6$ES*OER%ft${)hbS}13;)d0EqXtKNJ(?+&EH1GiewnPmfC zLU=>(*R1R0U41{bZjg<*OMZhSPpg*W3k>fJV{3sA;q`Wwcc)oio$tM!b^g#Kuee=~ z8(i!C&_3UUUj3llbi}qTZXnA<{j$k?u#QV?RA>B-u&l)^AP6et@mDL zbScUf^Ng_rpF()_z%((#Tsrtx?>J9M&&}R@A23fH2TTkyOQW}BGEH>hlhK{g@&3O{Kw&_55lP4QPSXOuZFGv=0Jo-`|i%l*AT z{S@gj1J?ToaC$h0^(I*uc4+vwe~jn(=+}_exnht1I#7T0Z!v}!;xAzj$QUrTY`}oAv5gSeR&2mV!j5A*(l8o{38NW#W@J!^ z+Zk|PlE!Y$jgvY}+CZ>x>$>TUo1|Y!UZJ>coHn;f+q^b6aSH`E$*a>izmj{K+q8NA z|JrBIIcLt94}I9leZL51oqg8+T6^ua*Is+=ea>0Ydbi~2$Jo5BwZATQ+XJnC5b9qz z3dm7VsC&=N$<{~eML&l=(EW3*gOdIsp?MAX|MAu-iG9)HX^0oC-|1pc{WWNKQTpgb ztNUu=xtF=7?vd`_XeB+LY<BbrUzYwUJAgw7sZ)1vS1KvD@1|Cer)3qI1FRTJ`fjBPl;G@Fjt(LW7$= zIPWhc{5JycwH~*ehi>~P}d zX#0;OTrVTBzAm@n3+?rFds@EGK2O4n5Wc3qOW>7A!(RU7+rHm^jf8IyxLF`MzgXQ} zM;h*~BMonFc7|c++_xZ%r!Myc z4y#`P98u2$?o)pXm{jKgC)B?I=2Uw}SRGVv0erVw1DIEv0UuWn0KQK>3iyP24Dc!S zIN;OjEZ{S0WoNVcef2@W&#Pwu@3a`c+hX`0>sJ8>txo{H&H8n~R|WqYA*T7Q5Yv1r z#5A7?{TATwhh7Bye2D2^k~CkGG=Cv!z9RS?b>{dqrSF0xg*Qvh&yjh(E>{I^&c$cb=^r!*V z0r;TW4j2=-Uu7ceU@yK9=~G#h*$4abna-GmV-k)d_DhS82lv@3yW6wcUd0whpPkS=KFSmJ6m=()1zCi;+IT^dZgvyR1*rY!^&a(!?Z9 zOfWH|>FAD0nz*%0eP!_xi9I5*N2G)!68pGCI^QGs6TsiteM0ch3FefPeA@b`8tOhR z_&*W+S;3z}`hDH!1plhwRfuh|Lek#QA^1`1LTqn+=mTp1iiVK1T4K8q`&@Uo#4Zgw3Ky1GMn>Y}brT3z=+_O;+6NP}LMl-+{qmXzI+a=Bnu0YYwp|5kUO;I|7tCb?pE z_>j8t%9zB)1(TQ9BgpmD?jwSKTd4qY(4pZTJWa@|B_(NNcyw&zahZCQ{e}2$>X2w_v)PUQj2myt0XWzOspY-qOT& z^+}pONfVQB%nrYx{^`mif;l3XBPe0@@?(ceO@pHfky;?MDWK2b3!mDC45TY zX~CS9G-m~KPB7;LW3@>Cwg^2f(!YY~7EHHbwg{$AFnxj<7EDxNLEv$Lrv#psG%o?Z z5IJi@)^bi_tybc#R;gEDx4=GuF@Z<$d7NiDk4gB1z>@+`3p^|E9Lo99Vjgyae6|VY z67Ck*E3i*sOkhFa5rM}Ao{(H8@M6=CEq`7xC)=paPD=Qcz|)fEG}4S-^)kXQM9xT> zGZK4N;5kWi4r!LHQ1eKSC9rNDscM4@SMi76 zv%orm5rIqF+1{lR?iP5ZV75rOS74vO;dZuYSi;eEwl^x_7}9@fabCg&2_KR0F@eVg zb3))Lfu{xk62joKgwG28oIn*8I>RipPQvvFzYvK?c&XsKCA>vouVDHlJS;F8UWRwe zswg_g6V0!0&K&@W%yzT<|9ab4uXL0?!CMEATt>rN0&k9|X26AZDqAS4p^c z0cnd0%rBruElBv7gpW)3q=ZjN_>6?lN?3I;z16`IA`)II;a-7Jf%y*VioC=Y1anL< z#{_d+Fee3bO2TIas!ryzI$82kfxS4G_)KS1U_szB=FBVQpccXx=fu|aZ183Auqi6K7QE;k?WX*k4ySf0?!IOFR@k^OO6O!DsW2|N97g?_ja+ysKA22;{s0!e5s4& zpON%uB>h>zTT6tK0=F#rwEDfsaS5LicyAvw76GbRA511{S_ZjzrCXV z3hI_C0l%_%TZEk17NHF@BH@z}Qhr9@dBL2QShbY+`lX`BB)mo7u)w^)V*;O*G|w(& znI{GFl3>&_;fcU4%Y+*e9+vR1g!2NA3FerDPfGZtgwF_6-BOOgZQVkDH|rYiW|_lR z5}p)z{z_`a`sIwhQsB1bA5dRgv28iWMSeNUIVSMgaQh?Tub~G zKuDTkP6{T{BY1)N9@cV9;2DAHI%0;eW15o!&j?i46B7}*Mc}Z&yudR8)f!17@Youb zb5h_Lfod%=5rJC-4hzf+e0(iO(6a(h3g#sVpOLUyCwT>K5x8v~xiKu^V**bKR5wUU zfm;L)3(N~VCh(-dE$c~bUf{9y|4wQJ4sT#MFYuValLF5OR2!vyfm;M_+epfXB|IYG zyo4W@@G%LW6nI8pkJ_@S z&MGY3vT3XJt)<5{N#6-PBT(HW{UUISz`Vd?0?!DH+$>ZH92S@tcuZhqGfUVaFu$28 zj|n^}FnzuVI^j|}d)_u2bZT&yh|L^+VhIGTH8((SsQR9-P z?M*-5^mx<9nqF%9=cbY7_cni_`IY8>XAV4t-^U8WY|{S1q+6T28Yt`}iv_F{PZF2UaK670P$ z!&_ai!tUz|brZaQH>+#0BYGY7fY)LV_*T^m|KC>Zi1w*F0sGZ<^;UH|-n4gzx(As1 zaQA@PiTCNUjZBQ>Dv!{-zg!dDl%W=eM^K{y$feZ=aR&KP8lZ;4+r~ z>ZOc*|4PEQU&h*XEAG7Z^9Zk6Ot?hC&ondq>+Aj)Fn`S#0e7$aE5NG-{*^!-tD&yt zS1w^Kq4k7*jGJa1`*xwqpX(om=G$&yIr}zz1Ms)k{1f2kH#z*<+Zmx_6p3d>?5x zEdCLo=JqF=Lsyt^_R?mApS*}=W(8h<0u!tip!)wdA7_m(N7|KTlHAgo)lbwfA8`_`@k+#>LA z*W7^cTNmF3SdRadWA|;?j=aCU<{m(&M(%gi;XF($^g{?bp$RYyTnOhq+5j&CE~Ku2 zmIy%?bO2rnEnz_?EJSz(GzHFdAyo+HKrR7(HDCxQMJ@x}2)%*R%g7yqp1^y~peecm zdy$*p>|6nOJ93Ah9aaP01)UOtuDA~H?a(+O^$xWTWex#`pe5EL90d%iy(rt_n;8)v zfllJXtD6u`LoeY>DQd&11VEfD!W$_q=$P9O&Y@vI9Cz_{08U>;iSwM;466RV@UlyG+aoXfsPB|)JYofA3 zORV<;UT%E=@Cxfmz=-urfJ?2TfXl590^ZPYYgzyf)klJaTLUn{PHvc3v<)cR|{|6+X&@PpRh0zPeh9q_}}HvoUxdIj(q>mL9=Vx0y2 z73&<}N3B-@f7SXH;ICQV0X$~?GvIOSyMUjtz6W^1`aa;Z*1rNiXZ-;1zgqtb@Y6V* z6H=eG{vGi5t^WZ01MA12{|^B}>T?$U@Kk_hh13_UI)wjkz!2UG-T?S@s|oObSS^6x zu-X8>X|)5sV$BCUZ*>5^YApo(Cu=d_x2%f*zinLt_%GIFfZwy00RGsz0?-OA#p$bw z&|v6Jl?mM!8dVR~t-;*-j=FV#qjl>6_tk9#d}rMzz+~OcfT_A$AcOxCDIZb)hLn$} z|3u11FsW<=4ApM}tgpWru(6)wcqK+zAI8Z5@*c#=s*gk3f1rk}DeL{#?^@rmzHh}t zlcApry*Kp1(8oh(LO%#K*WFe3hjlO4{axLn`X%*~_3x|ySp9#iZ)&)_VMW8;4SO2i z(eT}dA2u{MZfWdq+}-$K<4EJbHeS{Axu*YYx~cij=KGo_n}4qPcSO^TQaYY4tVhfVwy|rPhU>Q|szJ z$+KMQy2iV#CmMHH&onY>%X@g#qT-w!oaXTtPi(s4E<-@%hsLqR)rp% zw;I2@to`$LSP#y7SUoxKfci~@pPcuy^+)segl=u$6M9?w1EEaop3n>JFI(Sk-yf(${0aNS`sd^4_f_^k_lI#if{Dzq-NC)BiHPY5ra#Rv5IlIc|Z)+^QK zTQ?02t+{^adbN4`cp|qewKbEDj>Mwb-1bM~sobr5O)S$%vcdF@cy3>MWFRq?ismLW zai)=&JL0K$CYo~){i#GQ5ltrE<)BJ)yW?(+4GnEeWG9l*slH@1o0UR^K9V<>zH@T# z?TJjhH#Ks5Ix`l}-JeP1;ydEmY;;U2Sfi8ej33xGm5PohV!fHM$#Jw|aB?E)q}YBi z9-GuuN{-TMHIi&u%L031xpYSOAh)DP0)v^U9nlGCb0WrgjU|<(gcUQcD>lT%Xjcm) zp8c>pK9|hrqB{HcW`PVo@I4{7Vg}@Qtyc8w#7%IlgZqD(d49Vtwb=11bhSw zmbD=-I65B9p~gGo$q8L=G530w-w?~%khz*P&D_ngeIJB|6NRAB+4Q8T`#v!urz7ZwtoJ=O8dz10uHLBlkgMGIv zGZN3lN4&`Gk4#2$cKY5}4uZ~%yW`Q3U8&@hO{R@y+GHXJ?D#}96VJG+fP%u^ozd*R zfp`v~fjClN^o(A$r6K+NAZ5C{zr{`@YFc2E5o2O~J+(8QceTK7y#tw% z656^cB6~+h(0Ldq_i~_)CgLLsap?p7qkYj-EDpuM0dCJeh-CSieM9%96DSmXxpn{0 z(AH>dKcZcNJC4^AW#v4qz= z_a(GPto~@5pTv8jxqW`D%-p-9sr~*ayF9I(!1JNOXm)>AV9kl8#mwi=(VyKlL3I{Q z`r}+fduV4OAiYdD`_38)~4hZlkv^9TG^s~_a{!|{l zx+9v|k42BKQ~GUjFBd-;Kd4us0eOwE`b$NjdQ}{d3;I0k&tW$yAf|Le3rM2JRX_yi zjuaM9qtN;R(RSNwND`2F>trIC>rWYbm?O4)s>-n<A_**uCqu;Kyu?Q35c=j&#JF73S_jiNz}&^zmtrloQLMT$4*c3N9il zrx^7Yn<{ckXtnj8y&%!<0O6_=A?_Q&_1i|K+(0NW)62A^SKdW^p|Cg@5OGz}VkoN- zcf@mCy7#3=?9O9gSL(h*Hj&fC>?9^-;x%qC6W7V@<|^?Axjl~>Q`Tduqy0V@1<|2L zRl%+R>`y(K-j9ppxKRBR;Iz!fK`XD~5?j$9a}PaWn77sL$y6>eF1F#F5N%-4a1Id; zEgLhKF5|31J#^{WBWL@;Ts)P9+R#(mKyC`9c~X>!TR@6!@nn1qGe$rZiL%#lc4zu4 zfYyPVG&iNQQ*J1xrb%0;Kv@(MQdF>v)}+d<9^}OsTdd?B;!n?@ghl6qLYjW$5s@;a z-~cCycA^{?2ixMYWR#!#Ek>};^6QT(qg>@o`7Fk@G*P3@GDSJ+yVPA<^Z*ErQii>P zsU?$H?U0+gPdN&l|mP1v!>T|tK_bvWku#^IUh@keI^j>(}pUr zN0y{cQIbWI+zmyn;Bef_>rU(#$&i-4BT;yiHZ?H0SFTz6%4YOuZHqx-h|%&dw_5%s z2)eZWSxje-2D!IKLov?1zEm04VpHiY0li)!O_~PhK9P08yGDxz(qhnaSP|tJNm7n? z-6|+5!xHoz@mv6Q(zE8Z$>d-z)@MX}7wm~5(pdycb((iBq}y?}CzYL?pjRtC;!mg5 zNu?xWcvVVJrY^I*@ztq&*F`M*!lafKW?aj7_^QofNaDc8A{SgXKUIPI7RuYK^@T&O z;?6b`2irs<8PC`{ z*S6pT5*Qj>QQHs3l9MAcpHjK?rQs@xj>VnoilIH6;EQ)^TYT^2*qE%YjkC76li{Q) zX{-}r+BcZUVSQdK0lsrA(bE~>%8qCZO2`!plcyg}SZwDOGwj-%#o9mT!fZ>&vpdt+ z4W)mkf7D3|fsJ7T9)W@7AP1w|6~3Jgu>RwEsro>3oGW128i#WViZr+!XvfjS*rfKeIMsMM#X%cU)% zC~O5_GgQpKjFUufD7dT@C#pDKJ1F$|Ky);oo7#N(la#W_A#AULoe0fzy=riFH z=j4V$(Kpc3m@S+Lw}Y1Ri07VVm+{f6eZjt4HR3vFp@tsit{0X`=BSHrQo#`yM32M| z?i$teQ6eRJIy(?gj&j$Q!e=I)qQ6#cPsP$B7%iM3p~#EVu+o;FbH9zJTMjz+_7rA! zLyxThSP~m+yIHkRfYxHb76khqMqO40t7PI5L`@K|h`ZydF$BTNU8AE|abrDVqmnuX z8b6cE-k(6Ck@y7Qo=ife_r6ovYgKOgAUvMt);faQVZvnM1Cyhp@RMV1)-nS1g@O=G z=D|)J*_uq_jug=4ErFr~oYXisQSN9L6WL8JvexAamqN#@TrnaEpLAJKcS*_=$)K;RyXfvKJm zqI2SpCZ*-ezWh^{%)W|1RTq^#ymWHI%wj4NFx4SR)i8q4v-^l#5( z((a`FG7MaKa}--$-RA3W9U9WDAlpoxMdfNEirUpAFuLBp&+5`BE!fHtN#>RJJTPJF zGPxJ`C!Owa=%Ge?1;mw-PM$3W?NMm&|7fwn#G<&zGQdD>D{c%(U9oG=eGne3l#2N< zwkJ(u-6v;qV6rGzWx;#^~_sI=}*z+0w^HEsuZ z9PUYHv5jKSEjrd7x-f%yAde(EoUujTIS2tV#G~ZGcv3q~4_b|`RMMI5RlK-mK?v#t zdqnRgViYr11kBj}am+?so8hd}!5FkZGXOte7O4(aPDdC+bk`(i6LC2@3G}QP5Ft55 zKl`%}?Tp7q;H%gfAKN)O?k)^7bz%hT?2PcyiFs?*%R|?pJu=0`UXS8&;eDFMu-#E6 zwo;G+`#oJiho7MBt}3aMEEW{FuE(E!Cnt+gv$qQ|nNE)TvDzvxDOyuk9Q_hogD1@0 za2KzP0+nJs6tD^OMM(?=%a)#^M~z#wYDXfLNoUieIj?K3Z(v_EGhyr_c%&XteZYX9 z+!2!<5DC!Pd?&0_;Is`R+dH`1%WWQ9cje#$P-%f8-AGnEovC+tWzYuf3~OD5HnFcf zNj<3Iq&gDcmL5kl^jcoL4(PpNbM+ZpB~omMwJNf2TbJSz;d|8i4hACjP zGpuX!2|LNn7{3+A*2ImdJtsl+y6P)Q>=aj~b}&_ToNSvF?Q*i%i;B|tqK#e@6ZdAa zt028+L~EYzo`}QmyxluDgD*CS8v5tnB3JrWB76 z=-VQnL=L@obk68hVq|5D-eB>Qxzt7(P2-)xi$h=RuHxu7il0Nt*<5oCBiMG?H=-`G zwn#;3eWOM>l}2p7^#*Ju>`P3Sq=3QdVNV&mN6GYCOJ#d zv;Om?FOEf%maHlsVlYU~qCRA%?zPp@BJN&5>Gc#H;92p#xNgN= z;kw_Q&L*c)E`+1wi+YZ77MQ|TBW2?Q%w$(N+CFt5jJwLQeB6=d`2#&t%|V7NPW0#} zz95*|EWw%yhsgCJRCljglIpvn1iNSCtg~h8MHfv|d5Q~bGF^y$-b@6=gmpLD?m(VO z3XBkMwTZzJ!vD;ciS(4G*CByX#dSzvteFG@BX=aSa=<eOg_t* zIP8_mfjZ8?CU_4vCyF=Yc05M_q>bnKQIb6yX*)eDkKC9r6Be70wH+O-t-`ZrG^zCx zM9UaGhj-#}qMd11NfYK^gKmi30C)EmMZrC|9OJ;TL39a4T`x~r8e>4)N)E~%6>c;J zJqU&~2NSK?wbPq!cER?hgub(T%&gEg67Fsv9$nzW(RrMn^yA0857g*FxwaYc*25Xo zi}C7n+5F0?sE1-^;yP6u3C>-vh%X+LK>r{a`@F~rK30XCd}xq{W(M0h*v?I11ViX1 z;<)VO{GEvD?vl*h{db-hu_Nx7OxUO2U`Wd2uxy|mxs7HA&QaO7;=sj0F>~)&--@Z| zII~lFhM|pP5D%*8CDpR3WH9bT7BevImBA4;BU}22!K9A5=0vnp3i&rqUBbbU^XA zy&AwZ2mb)IZw7vIt{J2;_68735c6gij~w#JSp~wfIp>z$>r5o>GpaHl70-4`saoyZ zQ!Y0w)K;kUl#Sk=dNh$qr|1|f3SCe;?SW8SR-(Ogv8=S8V+yL#&Djdc-XOxr;tI98 ziE}62eCyhwp_qO+3!7M&<9Ff7D*g0{Jh(1W6^!#f;VymGm&V~l$wGgtUa^5!t|NyW z?~+tTwi53-$2eAXgg6F@(|}5z5>|cDY);)x5H(s7qc%$YAVqAAX5(_BCwlQt%l)7{ z$E>AL?ZEMko$-SxR3Ay9IZ?(|?2$N#GZ!;B8Y#EMsRhi@N?aUb&`3EcRWF%>W1KaM z)(jXxwoPWTi#UiqZ!n^nJs3Mp8c%4u9oQyAG1~9rHc8m!dKqVLro(VCapKDne?>rC z8GNzI;tr!Jtz@xp&^`rLT=Sb0#UeeZ$i6P)e8`&+TkMe8dvbrTyd*L&l{^5w zbqb@kctBWeVB1pC;lZ@N!qce(lz{%M4%5rBH9ayV{K9j+a%DeYS%Kxf*`!jvsVRG6 z!gHHbN=~?OW-ty-nI%%N%;b6M8djLHv8j704zD71Ib9x}0fRDU@wbmpAOT*P@(#QX zr3ddcQ4jCHyGq9JK9U&TeUid84aj$rB=F9X6yDu50L&!bMH0jP9fFJFE{d2muD!To zfl;7Nw5i7eh$>(!XDa*Gfh3Qk1Afr}3((F;5|JydEWjG`He~SFNZpidUhq zkO_oXWdyHg@e|0;UN|H&=OM`-L3;jUt-9VU>K(_wD2SZ0Ybi~|8Zvkl3mXyai2!|a&(i{()tJSN*J~@>tc0jUAq1lQY7&&jyj>=ktb*8 zB@Izvu%s0{ImlEA(88`Hm-m7LI!8j%1hq7ZHZkpFu_Rr?xa3R&miC{Q?w&IJa2?7k z-xCj_)Fj%r7i~!5)nzw9?52=|0yPd{+J-hz3Q|ZzEX9?A)`xr2n-Cns%)e4C!;5%^ z0wrh2BRNA=#G9pT6OJaN_CeG{`Q%VZfiOD_O!ZMYy5*|4_d?a#X);zPWbZ< zA}4keke3pnM~0S!YtUQ0pp%?E0B%eoMBYu{N_o2lzfs{BrKYqMly34rV{=u@xh^?a zy4_>)4&+QpZc3R}D}LG|=xIt+rM~y)a*rYJxGx=9o57LtQdgRqH0x2NM;p1K?+?f* z(<6a;fXXi-a>st#YxC3SIBFX$qm)L<33;c(MrRD;^-?%w2F_?H&)~IDERm|#q+tyE zHV3UaiC*hLik0Y5D%!N@G+j#sX`HgOa@HKzG5F9U%48a9j2^t`YP%XlXgyy4M{UIx z?LlvG6iq=6-25%&5nn!93r{CdC;7sWO3jnTza&B&$qvseNyx_F7D4)ISK@guSG70DQmTGw1av^a|%^Jj9Eu+lJ^B z9YMQ``kQl?w}rK6UUG+eoK~ZeLh38dFVsadp<@{&!D$EeU};OJD^sY^*u+_+p*>5C zV03W5UA1y%o=%U>hLgcFe6S^D+V60FCK5zT zb2b#~F=1#iS1pO&JNLNJYe3Gidc8x7l-6JbKdx_b29AnXwYb z3wv`)HECU{E(w}PI7ZZMT(eOl>lLlr+9cPx7SJ}Rkwa6G?hCbv`Q1`?k4QDw74#Sw z_m0+_nkqZzCCs@C8p))hMiQC=TjouvE(_{AH%-%%1v}?<(lqn_w@bM;xP)MvLoMu) zl^K08N!a1EpcOu_y4}_tez}92t8NHCIMX^xHMnYXIm6oBGqhTKANo_<_=D&jy(U+M zj~d67Sxg2SX~tpJjf|XV$1pgfVAcT<5{i#@P0=;tEVm+<{s-_D;|*$!x)G^$T`Q1R zPxox>3gET6q&r5lfy>~yEY(*?h{C)=)Wpo|Upwvksn}*x-;HST8oZ;~w3ka=nm%+d z>g5n!gL*ON<{KBxdeBe|dX%-;m@;nnq-r8vhm<U`)2WimSYY)op)zP{v_q?X9HKPl?o+)ZPb}WUN9q0ES z&CKgW-R-x1D^a43SZ<;Z1x~Em$-}0^AcKyhgk#X{7GZO=8<$Giaoc$rZA6f1qcHBN z=(Q2=ttW`-j`+|?!Mfb0%kVfaIbh55p&Vf0rZIOYnrgs`FCP6**mSCn~O5a zaX}qE)D6P8AF>C2$9}Bf9)Qn$t*w%W@CyAQSRK0o>6N@6zukeu#P3sgJeHiB=}D!q zarT}>hy#k#T0g?2w$v`*?uM{(fY3JJdNGagN|zUOx@DU3j9u1)&oa@c$KgVIos$je zGwF=Cy&E`s6v-j&mt7BDTwmnM9ca&X=&-?QaK=5yl=4H*9^)9U3DnD>t1UMUWj!I% zA|^NJiwx#p#@_EB?RxiRG_cRuBiJyakOw9)ZjlO`$*T5lX$gSemar6^TE zUiG9Ejyn1uZvAU?W2I5(=--)E8&qSk<~Q`{&R+>u1Z#Y75FM7JqtCR%uQI+$C2UYGbSfg)xoG*|!jSr8qiGe%IF+UEd2t=fK`3D^3e zwCJ3m!%A-}&5kzO@^f3F*J)w+UhaAuq;;+-=z%&M5p`W^b4-smZar%I#P50w;(Dpn z%ynPU9q6^8Dp^g2<1>-6+0XcXnSUe4=Nm!qT#nJ%(-$;KW?$;`#zXK}ojnylz2kNE zZJXJc_0HzrdDx6=bM-GdO-u|1TBYL{vs=#v9n7drD+Z;ieKw`bZzejeABHSB$#w5c z*Fr%yP-WZAu@`4X^Xz!lV;jfpX`B#8%bgYaX2jhJLz<`exY02a`ld%6EjBJ0#y|(n zeocY4Rvo%((@EO&UnzbLC$F|!r$<$vaD@l#G(B|ty7@%wdZ{?Nxj96)T6KGPw!J=k zNv+oN^V~~TISR_R!z*3o@|SDDT*zV; zV@)3_ilJ|-%?Y)(gbQzd=#3hcG861H4H}E|z>zLG1WP;FEKFbY>YHB(jywQ0$uax=SQq^?)%vsCIo!srU3(OJw4`BU8)m zPllbe&Q_J!H?=ifuLw+wO0Sh;E9nKV_HoZ7<>s|ov=McGx%}nk#nQQ_T>k0KNx|!b znNV1XkF^c;H-0WF$F=gk7Nk$hl~TU%ykktubR~Wn3C?;fnR4}(r{1x}{!g9(r{C_m z=ryBs)gz`is$I*?ndRs&JD2t`<|_Ovon`&&l(J>y|JVO{^Km&wl^1Y-N2>-7LzOl& zb5v&LA%S}Z#srQCD4i_naAg%8>TS^#qcM2%#8J0MKxUOsW7kUSSc4zJd~c~y;-T{W@uGB z(UkwFdz1!SI$p~r>zUQdZ}|t26?E9L+}w^6c=@BI4W(EAddbfN{nSn=XZ$3To;=X! zMcq&Gtt@I+WvK>Et!im0MZRH~|F}s~sq@@NJEqs={s+JOmRaSl|4{X=_jY!r;@I7O zl6dNdC-nVX&jz|Q(CNK~ZKc;zG33So-P1g85<|#rozUb7-s}jXF!)KV)K>5In9-thss{=!`7?QS6nnFTx{6K?A|x4dotSyC3E7FqJ;>cffTgW=Q_~ z?k5+Cnq77NhTu)P*d%wKP)~dA-w4N-yO}*Wp=MY>Pl(Dtxe7jXbCBCu(WZyWUA=?9 zTq^f)E0@MA1FA5SNGGZb0q@1Q994fX%R3kSl<2rrN7xG=cpC>_>xsWfbsWU;?OT^hsT zQ!b?V3IslmO<}U~-*?MY@O0oE`rethR=wLFFw=5`yPtm1r!&16y@m{)!~Oo=(h@ma zrcehruJG*x)CUWx&8Rqxh4&sZH|FY|uxDEB^rrb*SmW*_Luqhlnb=C5W|WL`W`AzG zv6Sh0)$BL|g3Oodo$08+Aa0m;&$Q22dhml6ret&Va<*2^`OPyvNW&)xg1F&Nt#>vf z^5_juV3a<@uH(zCSq$yws)v=o6vwlv%j?0uL1|5XYu=P9 z_2@N}Rl8O;CQa_jse)rM`5tL71(>T>z}<>tE=4U!#T>#jcR~1I%BrgoxBEmt2~+(! zO8xdR?!xOQEjiexaG0!git(0ho&(~lNIwTduRD#rG>kkx@2k7K_SVfMud6AdYJ4~R zcelrDPE_U&pNoGpIlmHebUmKltWB-3^$IKL+Ws-M_jrh@i+z6xj~+iJ|E|Fruju0| zSM+054nG8sT2orJ2d=zlc*^O2|9OaD(dK?#WrkKByk4p!@&d-GD(!djaL!nXS;H-Y z-cymz1NNM&*cs+5EMN7=<13Y^H+9w43X_^j$Z;Qd&y<=p<*t=`x00$bC3;ttD{Y?E z+D?`KkSVCzH3p+2i>6Y-IkMQ*J@ccAp}yR$ApA502&j-S3qaOy^PX8&Azl6p{Df@QF;m*+UyY zd_N?QM$?;hEr!P^;2`F!ap_sUVaYrxs*jj*Y1)IiueP_rJt&Wf({!RK$!GB&4xG)) z+ZTrRJMB5N+%7<+p;0RphNIP#sN-ngjTU+LeJT&MLvZZ;lBuTLbqJj^9V?zhxScb8 z=Sq1S9$OJDJo_zMRBOsnR9*_>Cd=G!S=|ANnSgIdTWQoR+Fq)q#-LM(v&-#$^lv(4 z1uYzOez(k4+9`ulb|*bl!w{-eTo7~oYr{UwtL6>R?%ECeVIbw-V{S^X{%7@rDy5+6 zH~O-7gEfOG+3P%TuRs)JFnIUQ|5hh&FIIo^(^h+q!!T*ORSXDqMG!L#m0-$cCR}=j z(#}6uiY&d?&wp}%jmr(aRmpd1PrBpaSFgOO!`SF4UC_MoOd#2{)mpky>Yl8F z--c3}gA!JHu)+WG+MrbQ&vF3r)!m%vOPODJN;Dl1tkq0x>6I_+;PbnD%e?MZ@8Z)f zid<^4<5${dhhBG#JUS>CK}~c^`A<)$ zm@e|pnua~4SIt;;e<{B7o?S|-)!8hm%n@C?>I)uJL9;a9lg)Rels@XN@_$)MOzFK> zedq;}aRty7!DUTt;_&4uG>-J(Pd*gljQbeHxkBLa>^qskUde6;5&LH@-8Tnx<5fdA9-FsX0S# zlU*&Iuss;?z+W%))|8y~anH5Xo2-Yk@68C=8s_nHwW(3=taBU5J7v=h4#HP&lI}-3 z0Qp%bngeuA2IUK4wV|fE@m|W<;I-sWa^??eb1;>qQ)^HvcbdDw)iLREo>`!i!Q4&H zBKEF1%lEju7yWL5S|(HSV)}GWZ$(R;On!{ZH4E9(63nT7I)+XV_le6ulHFx;?aVob z?;D#$5A1^p>`ztOlFb+hGgAQcb(=G2rQ;%Kl)2T%8>!H0(?D)&97C=$Cn!(Ll*$_8 zjw=H5M(Uhx@&(BO^9A8+_gSa{o^`k#h5#q4UQ{|_A6e5HxZ0@z)6wSY^}CfX*FF55 z4Rcc-< zN-JUQ%hHAi6*DDmKYmWwd^v3b%7T-YV^49^y6L4#=e~P6rRuGpt{;BnlP8i`Hoq{z zWy5w@aXgvr_|f$?;ml=fuJ~|2xWlE4K4_`GD?uNlqe9<&j;Iwzl*?Uh%eKYDt2+9W zFoNnf~Ldr>pLe}bFAW+L@;ZyczChuuqRXQ;WIQdWzJf zFLyPIBd6)wC~%a|Hc>gHeo>AIdQ>?Eolc(KTwabQT3YT`DAIeYw_EfE%XF>V(t3Di zbUJfwY5u(!7PKn%^ZeYN(%5qMwbg0QWrr7+E5_hwqDyv5S32{=o25y1dEReFeLxe8 zYcn2!qg%@y03QI(d=dR;8p`ywzCuG49`>TD-@Un7$t`3ZmrXCMenoN&s|bEMoNrvv)28z!GQIB! z`}DTb33!JL(9*96m)$LoIZw=cb5=JDjSZ#EP})%1n)2?s!G6AOdNisAt`Jm*ekPt@ ziRO3Ffw|XT&MbLYcdJqh{d0xtptsx8uR~^*V`@W_p69%Ly9d3;2ZbrUrTc*TtOCtz zZwz{Kqk9%4NByZv->x9Lh}ZEw2WEj#O&y}12l+0lT1Uw$S>f_|8vj@nR+H=TnbOkqs&*^i^d3ue(CliNEH)(BSzA{xhz~-iNZh)36?VJ?apTbiOmDz6H z>$KcU8@WUKgr8kvS=20EKDw2I!++~R)ADj9&s3F^4&3$FN^t8$e@ofFy8kL~Ot9r% z?a3A!2QSqo<%e?%zImEIGWV5I40sMfvpTq9E#wq6w|7?9qCfDg6+JBrE(^%4m`I_vLQqQ`OtiWO@q1XQ zi-HYH)ua!;Dtxe5Go0rk)cmbb27GLn7E}sn`R>CVpGi>HdOdoinkth1K>wBo&j8xC z!@>Z2VsVggsEZsW>X|JUI%A0kIXQ;Z9zWMg#bgG2Yv7?6mH((I+%4IBP=>RkTkfYI zoBT`&2Z`>qNsy;kUX@aF-uBABHY4;LWICRTk{X?zp$~SUYrEN)HFz%Wg$~I#SsrJmSEI)Np>MfLW&L+3i ze}8QyxHYZcR&Wom&2Yd6aVxl8T*2w5Jo!!0(gShca#3oH)K<1wyrl}Yt7~tcT3tKM zYIW_DsJiQvT2-s3h0CrWFGJ}^RG2CQ1xGG(Vy-36FxSMlluujQOZwx%o|@KAH}^2M za@11x%&5@HsfdefY5=1XVLx_PYM=IdsLSZ5C{1U_tub-c+hFHdUO9)IDpuPlsJ8<&D&6t z;zg`b^JBBES(_8_nbm%1cD0k2boS4v<-6w2G^fdrCxQKq2~q=EtvQbfQ22}km_|bB zOO9)I3kQnUgMO-l>hR~~0hcObdtf$Y&q8Pe#m3LK;5Hcxc!nYyI8Tk_)WzX#fuCnPJ%i#J5F#1U12;{+P zr%}rl2TfVE$~~QX4P!0Q1NIVAZRbe>9t?8io^?=d@=%k;4%+_MoxswaK{KB2behpT ziK4&k6ov)YiTkV?vA z{pQda6)bfbmpEL}vYuj@(NY;?JDoE|)uzT$84Zx~fzlehQtsuYmON@NMZiScb} zl|Bg6XPx-u(+jlI`E6bH~Oa3alq;h^K zp|7$$R4YNs*go4bq?9W2t>fY18hR$rD5zDH>C}304c_ciTS`7{QCrFlI6$vfSFU{z zW+!?Tr2ZPy3I#Q$t%ZgGd!C_%QjOkiGBaswMpc;|O7^^0ROWMg}$2r3cVj#cR725>3rRKQ+CzrKNK|=I#Uc z8|dX1`U6*0waR0)8UosI|7`eWe4PR1&XJFpdR9MhAl!LiHq<(0y>awXbH?R2dwQL+ z0_gSWE$^HetN}jA* zby@k+16p*bw7+X>k^8C39cT&nGx=Ih;%P7PK$-D828}2gDF;gHo=$(&T2nxqXV{D7 z+FZ7Mv(f}Xr3SRcH|y2be=MDICy&Tv&|h2!>R0xcV%@R{%PMfMu~x|ps?{m~C($}* zW)q2=^VT`#2ei&-am{t#@!f^=;iBIHedDv~H(ho>t7awjHEw|U`l&X~mG1hxb$(FI zmHhR!@~&DP0UY$rW3z9aW1)!WYgT>aZjmWBpcONmS%P##ux6^zW3!rBf+z^8E1=E3 zdTZ;sax+Wms)UpUZr29x&(tcRwbT;O*8B%br|-FKY^@W#sJGxf+?jHq)~W-zGC4D* z1j$?vyp4Peln;$-f7u(;|FzT-(9#*sUj6V9@wpzZPPH$WyQHN!#|I#J)zmSUyS z1KQ=ADQgpJe=R}nGWv4%bF#laQ+7a`eEgfsHaQmD8_`!z>2G$s9NX=UXqQuZK)Yr* zkN9OGNCt!EGTYMeX|LIhv!I#+TAM#IGo@KubKT}j5J7g+^Mz6(X4m#=)dujvH;d2Z zD0S20@|pPRoV!-*S_0ZR!!>Jd-R<>3$;kE9H@h}^YY1rHoN8NttBszQw)w2=>9wu& zynOlE0@^vlRhYjHYAHX~(frcV$7VM^tGCpt@6B(kGaI})ZFTAkXzNrdr)Q&w{QX)< z3BR|r>bVx@pvnVSFsDYKp9L-j>|^#^x45htp5GeJOu=UA*t+gqXLIqu*Z2kaZ&!8MZMn-XW+!Or2~fKK+Em7iU0H5|&V zvT+|Y8iO`Z^|RsjmZNVwW_GP8tM7bH&)TN7Qm3*1!6lbA_buFJ*Ot;@SGH}l;^8z7 zzOOD-qh21~4X4h#u%RhN%>AWlr^5?VQh?O^HovD+u5(a0pk$wfOsC|agR22`RNngg76>M93-c;sqawr2Gsn%b#uUXpuIshdmt%iFj9{P(~;$zz2$-dN>8 zu0Jo0ZQnt;zUflH2YJb<1ipH(4nG_XoK+b&pbQ-Mn>Hs)jwjA4KaMHRDnID=9Ru|C zq;vj=(DOg{ssmRF{CkI0<=IB6-L6Efo7E}QLfIc`0Qu>U})H{VuJF(#>bgm_FS zQ+HIRsNBrUvU0AMHB=iPj%;v=$dSckxIB=@Z|d@x2lP^v-ZT&E*M4l)JAQO8&n)*k zn{R$?R_-XQ`v9$7^SV-Am&>bPUdA5sAEd3G$F6N-?X~GcyLLXM!k_-$hR53W_a6Jl z^?!Bs6Yu@+{5XkKAF-_F27r#m42BybAu9|B#P-I;oqMc~E`5m*w?xMzni$hrxKXYh z`6u*!{%QMqp%H02^It~=q2|S%`4@3>p+2G(vdS)C3d@OUi71I&s2U=wv+#&r>c@nJ zkbS4>nyhC0T97r|phDqrxUnhJ5$WivZvt_^HaDs|V8hK#_01h!_}{p=BN}RMZbDNQ zs)ZJd>$+Hzbe812YIWql(*_bv_`0UH&ivz@1=W#%-{Ow^dn^{vnSXz0{z(ImcIH3S znSUB>?#O?HT!_6~g&JC!2)xVxDp=Lt6zVK& zktCh@qiuH9=McVhLCB^ZB)Utu+-hz`@l4Z!1{NdHWtS@{{pjkZ=Fa@LQP?M?dEqeG zrhECbo%zp7kWFHzpsi%3PK`+LUpk)wk&DlQDqwVaQuv}BmR<~pdzy$WpjGICqv5a+ z)RF%K{73K$=t>49_LPfLz%`qsklcj|LXPfznbk^Rx;wtW7*me)+bMxxlMXnpec4C_lBa1dF2L-khpvK4Mo7()n98ClJwig!q+1L!m8lMwWYYE~%g z>m7x!QV->y3e_oPnM7YV*`CtHhFZXVq{jcpn&x*F?iBIU!j2{`t?Mk*cjiAOl7b4M z77JaFl9iqLm(a;&;!$bYIFv+f`x^d-?eOcJ`PajG5ZR;BTiqpP3u}qgfgcO4g`rSm zm}9@t1?3b1(wJx_>T0=H%?NB-x zX;RYVs#)t*&PY@z?99U5w&G)5#UeuWjh%&8ThK*XvRj)tARy<3Ym4GtxYic$!nIP+ z8j4Fn!|zaN3g2ypoD{BQ0QspY!sti2U=o2;h=6^)mD7+=h)D+(au8h^X|p;CKjMIS~pk zXhIb>eT6Q_k1Zk+pwJY$E`nw%p^fx4Bjw?1kzkQb`du=~cXc(X`f#|bs|yU$O)W$^ z3lUQ)15#?lT`@*O;h~Nu_9Sb};eR+3W(6|fawZc4tTKO|m`^g$$ev!()zMV%%FO&i z2PAS~Q#~5kSy->*^RIUnhS8g-X2$}%VV#A8_z(NURCv%-co2dlL^Q)%K>^q22MwD zTpeCd!7rQ=^WlPwy{Ew>h}06(fD5_-7s93wKuZWz!=?ev%@`K!vBrp60#!<7MjHrf z^@3O{3|!VUF9g9^)meyRM50Z=F&^qP?x=uOc3z~@c_jd)V>;NJ%YdM|2h@ zi}^H@UWe4xfsV&8?MOd~38cd?{$MysR8u1?jSFCvNU|oM?3McqqRy}FQVm68M(Tt1 z!yxDtsbAF8;4eX%_ZzO}y=I#Cnj!NwZG}4bn(WuYm(qSHQq+v3N3pB*j9TV+Le_yI9Z z>~uwe(&-=&1!YsH$AO_&7%0mVax(wfT}=x>66YA)LV-&k>0sgAy1NRCZ7ROnSpW@4 z!=(@P(owBHMH$&Kri%`?UT=B0znJvX?qfjar^TW&*O<|C6iaAnZDG|4t{o^WBqV1h zKrb0NkYOszft80JhIDJzpqhosmaRfgS8FRlIOvIC(_5SBO+QH|z0~{{hZg?$ z%h$egZ}XZzy79hGZrHiL`BS$I{d~vQT5np!U5HUUBu0ObeqDW5T~6d9;ugvvG=lGt z^XXsxen>>qA4T6XUkXSMRNVgVtA3+ySE)nM?I~uIjFi!ZN_KmPFIXHPtv<18?`sE@oi{uQax1d<&r#z#m8>=;HtB? zL_ank2Mep00hENQj}b7Yz8S!Re`HBRs1g60>l!<{LX9CH!uWM9(6+kRrQ*Cn{A2ZvSi@m) zkbjz?r?^bm-ok{K6$^`sp$H@HWx5Lnhxyu0mw(NK3b|tFAalGMg%;jtaBy;=jvuj< zql~RL5rwW|=wgIy<;5hMnfR>4id(9cRcil^9i&%*iJoWjZS!@!tuwm9?e@K1VX^ur zm~K76U?(C=jC|tX29SS^p&bmp&d^A+E(pdV?)DYQI4}3fHoGLTCXrym5C=ohG%bIg z%y@jBE{MvH{OBw^WiVo|Notww7^jMvk4i{%FC&f>DR@2P1jEJPYYz6cu&F?71ap(8 zZ9s;6gyns#nDeMC6=6$)H?#}5F5o1}RG%uQx*+$zZ-}xxkb3uGCOp|;T3OVi2E#R& zp0y3e(WnNKFB%I)OmVI+($6WIb$!tgg_*e+>~eyUa05q-YPA#x4Mqq}W~%`v0@j%{ zqnkq*J{?^R3J%j|n$rX!_^zxF+^8_nyXY(J=t2^rB8^B$2P-l~T4?^$oyt5`2&w4= z4qC>iT7fXBG zAb?xM>06x$Q}!#`Qh5Soa%FFgt7XOOJP+#+)rHRH!o>uB9jX1nYp8I4?^&bW0{qI4t5tDji~7*MCs7C5n>0> z)ueH{?gEzD7HEEnwv(+UoglUWu#(%c2<@SNNtCF4jd+TI&a}%f>?npFlA;R_c~ib# zj9*_24eOM{x<$hw++rbjuuVyihwZRlrpY>;9QmenE%p^40vP;QF@j^z1BC~4_6LgX z$iMCcUt1UnQBu(sj!U_|R*c44AJHhyZe`AiIVik%cL#Xk#A8+d?qZVsg@q9;$hmxM zw%4Ob35fybaqK`CO%ZCNQyI2D6U|dt&)DIR`vwbB^yLNoZ*H~IBTUycQEV#WzHSE! zt0>1nA(Nf!3J4y3J&rft%tRcH`Hw81H$t-k3KIx$4J+!!xFFM4J1{A;io#+H%!3#b zpIw9jE0wyDPAPD^uoO?e9P_oK7j;GGo5i?8AqK%=rww}z%{V;@UkNIE9(5~eQUP+P zq>Tl=f5aO|zgozFi_Gqy^i*?eq>l7*RFnBKXX2hdW<3`)ONd@S$~Wc)N)rBb$@QQ` ze6!z{252P@ZhG!6z+Zwyre}+yQ0Q`k7hi_rZF%aluNT|b2;5yzw(UZI=^vB{-DU1{ z^KXQ9)Xl$9TE`pIeB%P-6uo7V6ORoqNel0QXt(dPDO^512S(VV2y-06!WGU3R3DIi z5gF|>Y=#;^HuUQb8ELQS``69=>nI!p?>utz0(T8GY2jg{g;i8+e*XNWk!DczBQVzV zx-CWd3vY=uLYw)}-Z6Mklx4(;9{!7_=;R93kThI&A?v`m=3bT zJQs>+=wg#N|5`Cv$T`7-lJDI`1bhW7;;5jTTbNtBcqD}3TTBU-nz9QQGiaOMlK(Y< zuLDv%O}hMfX~6|>p-U=IPSjBy6schs6Upe*PTY1dOT^@fAn80yHT6wp_eC=kO7UiQJQ<4P^I)Pg^L zK4M2+6X{RI@HH_eS>Lm!=fp!=~7pcznZ#>o=_3cztx;rqTGu8*bcq z!|3SVSp0^K>o;z=VO=ynvT2i2*I4*4VstDK+m!;jJ$=bUJeBJiNKa;B@jK$FcqW=l zXL|Oe61gd*ZnRYU?)XGHn*efZPbRs1UoJP1z3IB^#uB-GlY4t&>GA7q3a@iYRSE_! z_yh>sHg2h5C$3zLed&>SZz`Ic$|kZsPV&L2iFki%G`)KB_SED!sf%xmPsCFrpqg>n zTStb5*5R9oF-yI}$yQS>1My5EnoPVa$_{2Fed%N}9z#=IwG}JD!7H?6s4tz$<}#B^ zm5roFBRLWgIRJJfkMS!(`nyQm$yq~cn^0#`57GFZP89BUtlk4ICvL~I9c@Ww!h zN4=~lEEHtlD2q2Jm6BV3Pc*l$QFphbAksQ$C6v0#QjhOfNHrL0?@cDt2X;&*bBT#0 zUUL{~=}+wgx6lM8yL(Yh$yju?(jetOzKBbp(mFUEt7Qf$KmPfkWL9Zu^J*XkV;g+J zA86Wwi=U<^5MPZZWd4^%UuIzQ*sv}s5?D6VkIk?0VbRu;Ad1zyI-|6!EF{aX45HG< zl89YemA)p~)!IzjYUr-zmWtdHrCQ9zGdD#JQ6pZHdgQUl%0nDw45HoJEOnbRkTFId zO~m3zZHG+Cn@A1vKu=$KGL>T~IAUq3n+9^3cyv6G8oP6H?{xD+g|9v| zn0Be|m9FsZ>CAW(N^>6u^(tLq{)=GzAKNr)f>5UpxZ0@^rVWup9F5X$)12M$++-%j z1g2dMh6!(uP&LG}qWo?-&7EeIeqAN_$@ZK;ySbpB3wPoY3(a~%?*LZh4 zHI~~~RH6;ZL@K^UAdV!r!NZBM1T|Y!(;);gD5wBCY?-j<7R)ql+Y-^SR5}Z-jdyxp zr<1j7nZm%Jv|L=gb4@qBnK7h?mTF^d_TQ(nXa7T4JMLjsPvZCa^&$27i+HF1KnUD4 zIMaz=|Avt2zu1XmiUkC&zug1d2Co0%eQP%Ee$VYke&>!p>wOOOp(5?gB zh`Um94I-A0L}am*!Yv*9IJp$@srq+A4OsR@T0#z1`%8M8q`6+1e>Y%H4Lrb)bee57 z)-i<^>93)&_&(h8U5=!00`~{;;X$iNDc>8N#TF6|bWeEb3fkr=-3qF_W#zmR7z+ZM zPSdXYP_OG)J>u76D{BpYH{!>39mE$9EcA|foRpthPP$q)xAgU3r;=|_f)xR&gP{ug z_?^3?aCQPbB!|Yp#~ji;k3sI`>ovfTR(>;#f=SwU*?HKbEXlN;cYNSRVQ)0(Yme^D zv>r%BrENhskDWG5NFVckk9-58-kNpG#N5`a)M0fU+Uu>aw1=JkU9C2#P2kiT@F0#b z^fZ2J)ka*SY8~SEhTn~N;O0hweBlr$5puE-sc%5KC@>>PjkPKMZj^D*3u(>* s&mCueJ1l~c>6J8x4lQSr`Dfs#g9F!x6c=1CZTRUR=Vw&Bxg7Za0OJg!%m4rY From c29bbda2ebe95b351155771414d9c0f52e56185c Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Tue, 24 Oct 2023 17:50:21 +0900 Subject: [PATCH 64/66] Update build-release.yml --- .github/workflows/build-release.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c0ed8b005..39009d6bb 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -89,18 +89,44 @@ jobs: run: | rm -f ./src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/*.deps.json rm -f ./src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/*.pdb + + - name: Check update + id: check_update + run: | + git diff --exit-code || echo "::set-output name=changed::1" + - name: Commit files run: | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git commit -m "feat: Update MagicOnion.Client.SourceGenerator.Unity" -a + echo "::set-output name=sha::$(git rev-parse HEAD)" + + - name: Check sha + run: echo "SHA ${SHA}" + env: + SHA: ${{ steps.commit.outputs.sha }} + + - name: Create Tag + if: steps.check_update.outputs.changed == '1' + run: git tag ${{ env.GIT_TAG }} + - name: Push changes + if: env.DRY_RUN == 'false' && steps.check_update.outputs.changed == '1' uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }} tags: true + - name: Push changes (dry_run) + if: env.DRY_RUN == 'true' && steps.check_update.outputs.changed == '1' + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }} + tags: false + build-dotnet: needs: [update-packagejson] runs-on: ubuntu-latest From 6689b39128dd1ac9f02c3ecc43779164c0765c24 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Wed, 25 Oct 2023 10:35:43 +0900 Subject: [PATCH 65/66] Improve performance --- ...MagicOnionClientSourceGenerator.Roslyn3.cs | 29 ++++++++++--------- ...MagicOnionClientSourceGenerator.Emitter.cs | 5 +++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs index 513154167..c579e1157 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs @@ -1,5 +1,6 @@ using MagicOnion.Client.SourceGenerator.CodeAnalysis; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; namespace MagicOnion.Client.SourceGenerator; @@ -22,7 +23,7 @@ public void Execute(GeneratorExecutionContext context) foreach (var (initializerClassDecl, semanticModel) in syntaxReceiver.Candidates) { - var classSymbol = semanticModel.GetDeclaredSymbol(initializerClassDecl) as INamedTypeSymbol; + var classSymbol = semanticModel.GetDeclaredSymbol(initializerClassDecl); if (classSymbol is null) continue; var attrs = classSymbol.GetAttributes(); @@ -48,21 +49,21 @@ class SyntaxContextReceiver : ISyntaxContextReceiver public void OnVisitSyntaxNode(GeneratorSyntaxContext context) { - if (context.Node is ClassDeclarationSyntax classDeclSyntax) + if (context.Node is AttributeSyntax attrSyntax && + attrSyntax.Parent is AttributeListSyntax && + attrSyntax.Parent.Parent is ClassDeclarationSyntax classDeclSyntax) { - foreach (var attrList in classDeclSyntax.AttributeLists) + var attrName = attrSyntax.Name is QualifiedNameSyntax qualifiedName + ? qualifiedName.Right.Identifier.ValueText + : ((IdentifierNameSyntax)attrSyntax.Name).Identifier.ValueText; + + if ((attrName.EndsWith("Attribute") && attrName == MagicOnionClientSourceGenerator.MagicOnionClientGenerationAttributeShortName) || + (attrName == MagicOnionClientSourceGenerator.MagicOnionClientGenerationAttributeName)) { - foreach (var attr in attrList.Attributes) - { - var attrSymbol = context.SemanticModel.GetSymbolInfo(attr).Symbol as IMethodSymbol; - if (attrSymbol is null) continue; - - var attrContainingType = attrSymbol.ContainingType; - if (attrContainingType.ToDisplayString() == MagicOnionClientSourceGenerator.MagicOnionClientGenerationAttributeFullName) - { - Candidates.Add((classDeclSyntax,context.SemanticModel)); - } - } + var attrSymbol = context.SemanticModel.GetSymbolInfo(attrSyntax).Symbol as IMethodSymbol; + if (attrSymbol is null) return; + + Candidates.Add((classDeclSyntax, context.SemanticModel)); } } } diff --git a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs index bf266642a..63a5d316c 100644 --- a/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs +++ b/src/MagicOnion.Client.SourceGenerator/MagicOnionClientSourceGenerator.Emitter.cs @@ -10,7 +10,8 @@ namespace MagicOnion.Client.SourceGenerator; public partial class MagicOnionClientSourceGenerator { public const string SourceGeneratorAttributesHintName = "MagicOnionClientSourceGeneratorAttributes.g.cs"; - public const string MagicOnionClientGenerationAttributeName = "MagicOnionClientGenerationAttribute"; + public const string MagicOnionClientGenerationAttributeShortName = "MagicOnionClientGeneration"; + public const string MagicOnionClientGenerationAttributeName = $"{MagicOnionClientGenerationAttributeShortName}Attribute"; public const string MagicOnionClientGenerationAttributeFullName = $"MagicOnion.Client.{MagicOnionClientGenerationAttributeName}"; static class Emitter @@ -122,12 +123,14 @@ public static void Emit(GenerationContext context, ImmutableArray Date: Wed, 25 Oct 2023 10:48:47 +0900 Subject: [PATCH 66/66] Fix --- ...MagicOnionClientSourceGenerator.Roslyn3.cs | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs index c579e1157..91fe48e4e 100644 --- a/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs +++ b/src/MagicOnion.Client.SourceGenerator.Unity/MagicOnionClientSourceGenerator.Roslyn3.cs @@ -27,7 +27,7 @@ public void Execute(GeneratorExecutionContext context) if (classSymbol is null) continue; var attrs = classSymbol.GetAttributes(); - var attr = attrs.FirstOrDefault(x => x.AttributeClass?.Name == MagicOnionClientGenerationAttributeName); + var attr = attrs.FirstOrDefault(x => string.Equals(x.AttributeClass?.Name, MagicOnionClientGenerationAttributeName, StringComparison.Ordinal)); if (attr is null) return; // TODO: ReportDiagnostic var options = ParseClientGenerationOptions(attr); @@ -45,10 +45,12 @@ public void Execute(GeneratorExecutionContext context) class SyntaxContextReceiver : ISyntaxContextReceiver { - public List<(ClassDeclarationSyntax Node, SemanticModel SemanticModel)> Candidates { get; } = new(); + public IReadOnlyList<(ClassDeclarationSyntax Node, SemanticModel SemanticModel)> Candidates { get; private set; } = Array.Empty<(ClassDeclarationSyntax Node, SemanticModel SemanticModel)>(); public void OnVisitSyntaxNode(GeneratorSyntaxContext context) { + List<(ClassDeclarationSyntax Node, SemanticModel SemanticModel)>? candidates = default; + if (context.Node is AttributeSyntax attrSyntax && attrSyntax.Parent is AttributeListSyntax && attrSyntax.Parent.Parent is ClassDeclarationSyntax classDeclSyntax) @@ -57,15 +59,25 @@ attrSyntax.Parent is AttributeListSyntax && ? qualifiedName.Right.Identifier.ValueText : ((IdentifierNameSyntax)attrSyntax.Name).Identifier.ValueText; - if ((attrName.EndsWith("Attribute") && attrName == MagicOnionClientSourceGenerator.MagicOnionClientGenerationAttributeShortName) || - (attrName == MagicOnionClientSourceGenerator.MagicOnionClientGenerationAttributeName)) + if (attrName.StartsWith(MagicOnionClientSourceGenerator.MagicOnionClientGenerationAttributeShortName, StringComparison.Ordinal)) { - var attrSymbol = context.SemanticModel.GetSymbolInfo(attrSyntax).Symbol as IMethodSymbol; - if (attrSymbol is null) return; + if (string.Equals(attrName, MagicOnionClientSourceGenerator.MagicOnionClientGenerationAttributeShortName, StringComparison.Ordinal) || + string.Equals(attrName, MagicOnionClientSourceGenerator.MagicOnionClientGenerationAttributeName, StringComparison.Ordinal)) + { + var attrSymbol = context.SemanticModel.GetSymbolInfo(attrSyntax).Symbol as IMethodSymbol; + if (attrSymbol is null) return; - Candidates.Add((classDeclSyntax, context.SemanticModel)); + candidates ??= new List<(ClassDeclarationSyntax Node, SemanticModel SemanticModel)>(); + + candidates.Add((classDeclSyntax, context.SemanticModel)); + } } } + + if (candidates is not null) + { + Candidates = candidates; + } } }